[英]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.
我有一个数据网格,它利用RowDetailsTemplate显示有关该特定行的一些高级信息。 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
– Menashe 1小时前
Thanks! 谢谢!
Menashe 梅纳什
Just put this together and it seemed to work... I added a MouseDown handler to the grid in the RowDetailsTemplate: 只需将它们放在一起,它似乎就可以工作了……我在RowDetailsTemplate的网格中添加了MouseDown处理程序:
<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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.