C# WPF treeview双击上下左右箭头 反而触发了 treeview的双击事件

tech2023-05-19  100

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; } } }
最新回复(0)