Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 1.48 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Event trigger is not working inside ItemControl in MVVM
  2. <ItemsControl
  3.     x:Name="transcriptionTextControl"
  4.     ItemsSource="{Binding MyCollectionOfTranscription, Mode=TwoWay}">
  5.     <ItemsControl.ItemTemplate>
  6.         <DataTemplate>
  7.             <StackPanel>
  8.                 <HyperlinkButton Content="{Binding Time}">
  9.                     <ToolTipService.ToolTip>
  10.                         <ToolTip Content="Time"/>
  11.                     </ToolTipService.ToolTip>
  12.                     <i:Interaction.Triggers>
  13.                         <i:EventTrigger EventName="Click">
  14.                             <i:InvokeCommandAction
  15.                                 Command="{Binding HyperLinkButtonCommand}"
  16.                                 CommandParameter="{Binding
  17.                                     ElementName=transcriptionTextControl }" />
  18.                         </i:EventTrigger>
  19.                     </i:Interaction.Triggers>
  20.                 </HyperlinkButton>
  21.                 <sdk:Label Content="{Binding Description}"/>
  22.             </StackPanel>
  23.         </DataTemplate>
  24.     </ItemsControl.ItemTemplate>
  25. </ItemsControl>
  26.        
  27. <i:InvokeCommandAction
  28.     Command="{Binding HyperLinkButtonCommand}"
  29.     CommandParameter="{Binding
  30.         ElementName=transcriptionTextControl }" />
  31.        
  32. <i:InvokeCommandAction
  33.     Command="{Binding HyperLinkButtonCommand,
  34.               RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
  35.     CommandParameter="{Binding
  36.         ElementName=transcriptionTextControl }" />