I've searched all over for this - while there is PLENTY on binding a checkbox, I couldn't find anything on programmatically setting the box as checked, and the solutions that I thought I'd found didn't work.
The XAML:
<CheckBox Content="" Height="16" HorizontalAlignment="Right" Margin="0,297,118,0" Name="checkBox1" VerticalAlignment="Top"
Command="{Binding CheckCommand, Mode=TwoWay}" CommandParameter="{Binding IsChecked}">
</CheckBox>
The VieModel:
private bool isChecked;
private ICommand checkCommand;
public bool IsChecked
{
get { return isChecked; }
set
{
isChecked = value;
OnPropertyChanged("IsChecked");
}
}
public ICommand CheckCommand
{
get
{
if (checkCommand == null)
checkCommand = new CommandBase(i => Checkprocess(i), null);
return checkCommand;
}
set
{
checkCommand = value;
OnPropertyChanged("CheckCommand");
}
}
public void Checkprocess(object sender)
{
}
public MyViwModel()
{
IsChecked = true;
}
The value of IsChecked and isChecked DO become true, however the checkBox1 value remains unchecked.
What obvious thing am I missing here?