Hi people,
I just started looking into Caliburn Micro and I started up with a simple login page implementation.
My page xaml looks like this
But until I click the login for the first time, the login button is always enabled.
Please help me fix this.
I just started looking into Caliburn Micro and I started up with a simple login page implementation.
My page xaml looks like this
<StackPanel Grid.Column="1" Grid.Row="1">
<StackPanel Orientation="Horizontal"
Margin="2">
<TextBlock Text="Login name"
Width="100"/>
<TextBox x:Name="LoginName"
Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="2">
<TextBlock Text="Password"
Width="100"/>
<TextBox x:Name="Password"
Width="200" />
</StackPanel>
<Button x:Name="Login"
Content="Submit"
Width="100"
Margin="2"/>
</StackPanel>
And my view model class looks like thispublic class LoginViewModel : PropertyChangedBase
{
private string loginName;
public string LoginName
{
get
{
return loginName;
}
set
{
loginName = value;
NotifyOfPropertyChange(() => LoginName);
NotifyOfPropertyChange(() => CanLogin);
}
}
private string password;
public string Password
{
get { return password; }
set
{
password = value;
NotifyOfPropertyChange(() => Password);
NotifyOfPropertyChange(() => CanLogin);
}
}
public bool CanLogin
{
get
{
return !string.IsNullOrWhiteSpace(LoginName) && !string.IsNullOrWhiteSpace(Password);
}
}
public void Login()
{
}
}
I am not sure if there are any mistakes in this.But until I click the login for the first time, the login button is always enabled.
Please help me fix this.