xaml:
1 <!-- TreeViewItem --> 2 <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"> 3 <EventSetter Event="MouseDoubleClick" Handler="MenuItem_Click" />
cs:需要做判断,防止响应两次
1 private void MenuItem_Click(object sender, RoutedEventArgs e) 2 { 3 TreeViewItem tviSender = sender as TreeViewItem; 4 if (tviSender.IsSelected) 5 MessageBox.Show("treeview被双击了"); 6 }
WPF的TreeView添加鼠标双击事件MouseDoubleClick执行两次
原文:https://www.cnblogs.com/hosseini/p/15069379.html