Hi all,
I have 2 ViewModels. One is called User (containing basic information, nothing fancy) and another called Group, which has as a property, an IEnumerable of User. This IEnumerable is backed by a dictionary (there are a lot of users, need to search them fast)
public class Group
{
#region Fields
private Dictionary<string, User> userLookup;
#endregion //Fields
public Group()
{
userLookup = new Dictionary<string, User>();
}
public User[] Users
{
get
{
return userLookup.Values.ToArray<User>();
}
set
{
foreach (var user in value)
{
if (!userLookup.ContainsKey(user.Login))
userLookup.Add(user.Login, user);
}
}
}
public bool AddUser(User user)
{
if (userLookup.ContainsKey(user.Login))
return false;
userLookup.Add(user.Login, user);
return true;
}
}
Now, The GroupViewModel class needs to add a new user, but all the GroupViewModel gets shown is UserViewModels, and the Add functionality only accepts type User. Currently i have an Internal function on the UserViewModel which exposes the underlying User object, i was just wondering if that defeated the purpose of using MVVM.
Thanks!