Yes, set up a double-click handler on the ListView
itself. Then in the handler, use code like this:
private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (TryFindParent<GridViewColumnHeader>(e.OriginalSource as DependencyObject) != null)
e.Handled = true;
}
Where TryFindParent
is defined as:
public static T TryFindParent<T>(DependencyObject current) where T : class
{
DependencyObject parent = VisualTreeHelper.GetParent(current);
if (parent == null) return null;
if (parent is T) return parent as T;
else return TryFindParent<T>(parent);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…