Reputation: 1109
I am rather new to bindings and WPF, but I've been able to do a few interesting things with bindings (interesting to me at least)
Does anyoine know if it's possible to bind an event (For example a SelectionChanged o Click event, etc) to a property (For example: IsChecked, IsEnabled, etc)?
I know I can bind properties with the Path property and all.
Upvotes: 2
Views: 1590
Reputation: 10789
If you want to bind events to Commands you can do it through Attached Behavours. Have a look at this blog as to how to do that with MVVM Light. Binding to IsEnabled
does not make much sense
An example they give is:
<Button>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click" >
<i:InvokeCommandAction Command="{Binding FooCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
In ViewModel
public MyViewModel()
{
//set it as a toggle for example
FooCommand = new RelayCommand( () => IsChecked = !IsChecked );
}
public ICommand FooCommand { get; private set; }
public bool IsChecked
{
get { return _isChecked; }
set { _isChecked = value;
RaisePropertyChanged("IsChecked"); }
}
Upvotes: 2