יום ראשון, 3 באפריל 2011

Add Double Click Event on TreeNode in Style


Followin code adding MouseDoubleClick Event to TreeView control in Style tag of XAML.
I think it' clear enough without explanations: 

 <TreeView Grid.Row="1"    
  x:Name="MainTreeView"
  Background="Transparent"
  HorizontalAlignment="Stretch"
  ItemsSource="{Binding List}"
  VerticalAlignment="Stretch" 
  ItemTemplate="{StaticResource ClassificationTemplate}" 
                 <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
                    </Style>
                 </TreeView.ItemContainerStyle>
 </TreeView>


Code Behind:

private void OnTreeNodeDoubleClick(object sender, MouseButtonEventArgs mouseEvtArgs)
{
   .....add your code here                    
}

תגובה 1: