EventToCommand
is a custom behavior. It is first provided by Expression blend team and now Part of WPF 4. If you're not using WPF4. you require Blend SDK from here.
Behaviors encapsulates functionality as reusable components. These are to be used when feature is not present by default. For example Adding Command support to Label, Combobox etc.
can we use RelayCommand directly with EventTrigger, no need to use EventToCommand?
No. RelayCommand
is a shortcut to avoid code redudnency to define custom commands.It extends ICommand
whose delegates can be attached for Execute(T)
and CanExecute(T)
. It is similar to DelegateCommand
of Prism library.
<cmd:EventToCommand x:Uid="cmd:EventToCommand_1" Command="{Binding Form_MouseLeftButtonUpCommand}" PassEventArgsToCommand="True"/>
In above line cmd:EventToCommand
is additional feature to the underlying control. Form_MouseLeftButtonUpCommand
is the Command
it executes. This command can be encapsulated as RelayCommand
.