in my silverlight application, I have a checkbox :
<CheckBox Content="Check me" Checked="CheckBox_Checked" IsChecked="{Binding IsChecked}" />
IsChecked property is binded to a property in my viewmodel :
private bool isChecked;
public bool IsChecked
{
get
{
return isChecked;
}
set
{
if (isChecked == value)
return;
isChecked = value;
OnPropertyChanged(new PropertyChangedEventArgs("IsChecked"));
}
}
In my viewmodel, I have :
public MainPage()
{
InitializeComponent();
IsChecked = true;
DataContext = this;
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
// IsChecked = true fired the event
}
The problem is that the checked event is fired althought I’m setting the IsChecked Value manually. This values comes from configuration and is setted as initial value and shouldn’t fire event that does business …
How can I avoid this event to be fired ?
(this is a easy-to-reproduce sample, in fact, the event is bound to a command)
Thanks in advance for any help
I would wire up the event handler after initialization: