简体   繁体   中英

Double clicking on WPF datagrid WITH RowDetailsTemplate

I have searched and searched and found no answer. I have a datagrid which utilizes the RowDetailsTemplate to display some higher-level information about that particular row. However, when the user double clicks on a row, I would like to display a separate form which displays much more detailed information. How can I accomplish this?

I forgot to mention: On double click, I want to open the detail WITHOUT seeing the row details template! – Menashe 1 hour ago

Thanks!

Menashe

Just put this together and it seemed to work... I added a MouseDown handler to the grid in the RowDetailsTemplate:

<Grid>
    <DataGrid x:Name="DataGrid1">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding}"  />
        </DataGrid.Columns>

        <DataGrid.RowDetailsTemplate>
            <DataTemplate>
                <Grid MouseDown="Grid_MouseDown"  >
                    <TextBlock >This</TextBlock>
                </Grid>
            </DataTemplate>
        </DataGrid.RowDetailsTemplate>
    </DataGrid>
</Grid>

And the code behind:

private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
    {
       //Open the window here
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM