Please try this: In Xaml:
<Grid>
<Button IsDefault="True" Content="Login" Height="27" Width="75" CommandParameter="{Binding ElementName=XXXXXXXX}" Command="{Binding LoginCommand, Source={StaticResource LoginController}}" Grid.Column="1" Grid.Row="7"/>
<Button Content="Cancel" Height="27" Width="75" Grid.Column="3" Grid.Row="7" IsCancel="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding CancelCommand,Source={StaticResource LoginController}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Label Foreground="White" Content="User Name:" Grid.Column="1" Grid.Row="1"/>
<Label Foreground="White" Content="Password:" Grid.Column="1" Grid.Row="3"/>
<TextBox x:Name="UserName" HorizontalAlignment="Left" Width="130" Height="27" Grid.Column="3" Grid.Row="1" Text="{Binding UserName, Source={StaticResource LoginController}, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true, NotifyOnValidationError=true}"/>
<PasswordBox HorizontalAlignment="Left" Width="130" Height="27" w:PasswordHelper.Attach="True"
w:PasswordHelper.Password="{Binding Password,Source={StaticResource LoginController}, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=true, NotifyOnValidationError=true}" Grid.Column="3" Grid.Row="3" />
</Grid>
In ViewModel:
public ICommand LoginCommand
{
get
{
return new RelayCommand(OnLogin, IsEnable);
}
}
public void OnLogin(object param)
{
//code
}
bool IsEnable(object obj)
{
//Code for you button enable for example "return false;"
}
Hope this will help you.