2012-04-26 9 views

Odpowiedz

10

przewijania w Nagłówek nd jest częścią siatki, ale nie obsługuje podwójnego kliknięcia, więc zdarzenie "pęcznieje" aż do siatki.

Nieeleganckim rozwiązaniem jest nieco dowiedzieć się, "co zostało kliknięte" przez średnie źródło zdarzenia lub współrzędne myszy.

Ale można też zrobić coś takiego (niesprawdzone):

<DataGrid> 
    <DataGrid.RowStyle> 
    <Style TargetType="{x:Type DataGridRow}"> 
     <EventSetter Event="MouseDoubleClick" Handler="OnRowDoubleClicked"/> 
    </Style> 
    </DataGrid.RowStyle> 
</DataGrid> 
+0

dziękuję bardzo to działało w porządku –

1

Można sprawdzić dane o przebojowym punktu, wewnątrz zdarzenia click mysz -

DependencyObject dep = (DependencyObject)e.OriginalSource; 

// iteratively traverse the visual tree 
while ((dep != null) &amp;&amp; 
     !(dep is DataGridCell) &amp;&amp; 
     !(dep is DataGridColumnHeader)) 
{ 
    dep = VisualTreeHelper.GetParent(dep); 
} 

if (dep == null) 
    return; 

if (dep is DataGridColumnHeader) 
{ 
    DataGridColumnHeader columnHeader = dep as DataGridColumnHeader; 
    // do something 
} 

if (dep is DataGridCell) 
{ 
    DataGridCell cell = dep as DataGridCell; 
    // do something 
} 

Więcej informacji: http://www.scottlogic.co.uk/blog/colin/2008/12/wpf-datagrid-detecting-clicked-cell-and-row/

0

miałem ten sam problem i rozwiązać go z tym:

DependencyObject src = VisualTreeHelper.GetParent((DependencyObject)e.OriginalSource); 
if (!(src is Control) && src.GetType() != typeof(System.Windows.Controls.Primitives.Thumb)) 
{ 
    //your code 
} 

Czytałem to dostać idea: How to detect double click on list view scroll bar?

mam nadzieję, że to pomoże :)

Powiązane problemy