xaml中加入
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
</Style>
</TreeView.ItemContainerStyle>
cs文件中 加入
private void OnItemMouseDoubleClick(object sender, MouseButtonEventArgs args)
{
if (sender is TreeViewItem)
{
if (!((TreeViewItem)sender).IsSelected)
{
return;
}
}
}