<TreeView x:Name="treeView" Margin="0,0,20,28" Grid.RowSpan="2" >
<HierarchicalDataTemplate ItemsSource="{Binding xx}" >
<TextBlock Name="tbk" Text="{Binding 部门}" Padding="2" >
<i:Interaction.Triggers >
<i:EventTrigger EventName="MouseRightButtonDown">
<i:InvokeCommandAction Command="{Binding Path=TbkComm}" CommandParameter="{Binding ElementName=tbk}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Name="tbk" Text="{Binding 部门}" >
</TextBlock>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
后台
private static UICommand tbkComm;
public static UICommand TbkComm
{
get { return txtBoxComm; }
set { txtBoxComm = value; }
}
public void getDateSet()//这个是构造器
{
TxtBoxComm .ExecuteAction = new Action<object>(事件);
}