Possible Duplicate:
How to add a Blend Behavior in a Style Setter
when I use an interaction trigger in a style, I am getting the following error, 'triggers is not attachable element of type style'. Any explanation what this error actually means and how to solve it.
For reference take a look at MVVM Light toolkit's EventToCommand example.
In this particular case, I am using Timeline control from Infragistics which represents events as EventTitle and when the EventTitle is clicked, I would like to raise the command (Note that Timeline control doesn't define any event like EventTitleClicked). Currently I am able to achieve the functionality by using events and calling my ViewModel method from the code behind, instead I would like to invoke the command directly from xaml.
<Style x:Key="EventTitleTopStyle" TargetType="igTl:EventTitle">
<!-- The following is not working -->
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<!--<cmd:EventToCommand Command="{Binding MyCommand}" />-->
</i:EventTrigger>
</i:Interaction.Triggers>
<!-- Using event setter instead to achieve the same -->
<EventSetter Event="MouseLeftButtonDown" Handler="TopTitleMouseLeftButtonDown" />
....
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="MouseDoubleClick">
<behaviours:ExecuteCommandAction Command="{Binding Path=DataContext.YourCommand, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}"
CommandParameter="{Binding }"/>
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With