WPF interaction calls style for invoking commands in View Model

Possible duplicate:
How to add Blend behavior in style customization

when I use a style interaction trigger, I get the following error: "triggers are not an attachable element of type style". Any explanation of what this error actually means and how to solve it.

For reference, check out an example of the EventToCommand MVVM Light toolkit.

In this particular case, I use the timeline control from Infragistics, which represents events as an EventTitle, and when the EventTitle is clicked, I would like to raise this command (note that the Timeline control does not define any event, such as EventTitleClicked). Currently, I can achieve functionality using events and calling my ViewModel method from the code behind, instead I would like to call 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" />
    ....
+5
source share
2 answers
<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>
+2
source
<TextBox x:Name="EditableControlTextBox" Loaded="RoomTextBox_Loaded">
         <interactivity:Interaction.Triggers>
              <interactivity:EventTrigger EventName="LostFocus">
                     <!--<cmd:EventToCommand Command="{Binding MyCommand}" />-->
              </interactivity:EventTrigger>
          </interactivity:Interaction.Triggers>
</TextBox>
-3
source

All Articles