I am using a Button
to change my IsSelected
property. I am using MVVM Light's ViewModelBase
to raise PropertyChanged event.
Model
private bool _isSelected = true;
public bool IsSelected
{
get
{
return _isSelected;
}
set
{
Set(IsSelected, ref _isSelected, value);
Messenger.Default.Send(Message.message);
}
}
//ICommand
public const string isSelectedCommandPropertyName = "isSelectedCommand";
private ICommand _isSelectedCommand;
public ICommand isSelectedCommand
{
get
{
IsSelected = !IsSelected;
return null;
}
set
{
Set(isSelectedCommandPropertyName, ref _isSelectedCommand, value);
Messenger.Default.Send(Message.message);
}
}
View
<Button Command="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> Click </Button>
This set of codes works successfully if I use ToggleButton
's Ischecked
property. This code is working EXCEPT for the button. I think there's something I missed.