如何双击DataGrid项目打开更详细的视图? [英] How can I make double clicking on a DataGrid item open a more detailed view?

查看:115
本文介绍了如何双击DataGrid项目打开更详细的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅任何基本错误 - 我是新的实体框架和WPF。



我在TabControl中有一个DataGrid。网格绑定到一个实体框架模型。



我的最终目标是能够双击DataGrid中的一行,并打开一个新的选项卡详细查看同一记录。



到目前为止,我已经能够捕获双击事件:

 < Style TargetType =DataGridRow> 
< EventSetter Event =MouseDoubleClickHandler =MemberRowDblClick/>
< / Style>

但无法识别C#中点击的行。



我也不知道是否有一个聪明的方式来回到行中的数据。即如果我想与记录的内容做某些事情,从一个行索引返回的方式是多么容易?



抱歉,一次提出两个问题,但是我

解决方案

虽然声明为类型 Object ,事件处理程序的发件人参数包含触发事件的行。



Casting 发件人 DataGridRow 应该给你所需要的。


Please forgive any basic errors - I'm new to both Entity Framework and WPF.

I have a DataGrid in a TabControl. The grid is bound to an Entity Framework model.

My end goal here is to be able to double click on a row in DataGrid and have a new tab open with a more detailed view of the same record.

So far I've been able to capture double click events:

<Style TargetType="DataGridRow">
    <EventSetter Event="MouseDoubleClick" Handler="MemberRowDblClick" />
</Style>

But unable to identify the clicked-on row in my C#.

I'm also not sure if there's a smart way to get back to the data from the row. I.e. if I want to do something with the contents of the record, how easy is it to go back from a row index?

Sorry about asking two questions at once, but I have a sneaky suspicion that one will affect the other.

解决方案

Though declared as type Object, the sender parameter of your event handler contains the row that fired the event.

Casting sender to DataGridRow should give you what you need.

这篇关于如何双击DataGrid项目打开更详细的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆