im working with the Silverlight CheckBox and RadioButton, and have the following scenario:
DataContext:
public class ViewModel : INotifyPropertyChanged
{
bool isChecked;
public bool IsChecked
{
get { return isChecked; }
set
{
isChecked = value;
InvokePropertyChanged("IsChecked");
}
}
public void OnCheckBoxChecked()
{
// This function is run when the CheckBox Checked event triggers
}
public event PropertyChangedEventHandler PropertyChanged;
void InvokePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
View:
<UserControl x:Class="KSLog.Frontend.Features.CaseOverview.Views.CheckBoxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" Checked="HandleInViewModel"/>
</Grid>
</UserControl>
When you click the checkbox, 'ViewModel.OnCheckBoxChecked' is run before the 'ViewModel.IsChecked' is updated via the binding. Although the 'CheckBox.IsChecked' has been updated.
Is this a bug or a designchoice? It seems as a bug to me! Otherwise the event should have been called Checking? :)
Any one got any thought on why this is the case?