|
Hello,
I seem to be going round the houses on this one, and I am hoping that someone will be able to help me out.
I have the following Model Class, LoginCredentialModel, which ultimately inherits from PropertyChangedBase:
/// <summary>
/// The login credential model.
/// </summary>
public class LoginCredentialModel : BaseModel<LoginCredentialModel>
{
/// <summary>
/// The user name.
/// </summary>
private string userName;
/// <summary>
/// The password.
/// </summary>
private string password;
/// <summary>
/// Gets or sets the user name.
/// </summary>
public string UserName
{
get
{
return this.userName;
}
set
{
this.userName = value;
this.NotifyOfPropertyChange(() => this.UserName);
}
}
/// <summary>
/// Gets or sets the password.
/// </summary>
public string Password
{
get
{
return this.password;
}
set
{
this.password = value;
this.NotifyOfPropertyChange(() => this.Password);
}
}
}
Then, within my ViewModel class, I have the following property, LoginDetails, that is an instance of the above class:
/// <summary>
/// Gets or sets the login details.
/// </summary>
public LoginCredentialModel LoginDetails
{
get
{
return this.loginCredential;
}
set
{
this.loginCredential = value;
this.NotifyOfPropertyChange(() => this.LoginDetails);
this.NotifyOfPropertyChange(() => this.CanAuthenticateUser);
}
}
Within my View, I then use deep linking of the properties of the LoginDetails property to bind to the UI:
<toolkit:PhoneTextBox x:Name="UsernameText"
LengthIndicatorVisible="False"
Margin="-10,-5,-10,8"
InputScope="EmailUserName"
ActionIcon="/Resources/Images/clearboxicon.png"
Text="{Binding LoginDetails_UserName, Mode=TwoWay}">
Now, to an extent, this seem to work really well. If I set some breakpoints on the set method of the LoginCredentialModel class, I can see that when I change the values in the UI, the corresponding backing variables get updated.
However, when I do this, I also expect that the set method for the LoginDetails property on the ViewModel should also get called, however, this doesn't seem to be the case. As a result, the guard clause that I have for CanAuthenticateUser is never
getting actioned.
Have I missed something here, or what am I doing wrong?
I did have this working by having individual properties for UserName and Password within my ViewModel, but I wanted to try to combine these into a single object.
Thanks in advance!
Gary
|