WPF的TreeView添加鼠标双击事件MouseDoubleClick执行两次

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执行两次

上一篇:CFS调度1-buddy


下一篇:Android——SystemProperties的应用