C# WPF treeview双击上下左右箭头 反而触发了 treeview的双击事件
程序员文章站
2023-12-28 10:52:10
...
xaml中加入
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
cs文件中 加入
private void OnItemMouseDoubleClick(object sender, MouseButtonEventArgs args)
{
if (sender is TreeViewItem)
{
if (!((TreeViewItem)sender).IsSelected)
{
return;
}
}
.... do stuff.
}