从 DataGrid WPF 将 selectedItem 作为 CommandParameter 传递
我有一个数据网格,其中有一个超链接列
当用户单击此超链接时,我想打开一个表单,在其中显示所选员工的工资细目。请让我知道如何将所选记录的 EmployeeId 作为命令参数传递,以便我可以显示详细信息。
I have a Datagrid, which i have a Hyperlink column as
When user clicks on this hyperlink i want to open a form on which i will be showing the salarybreakup for the selected Employee. Please let me know how can i pass the EmployeeId of the selected record as command parameter, so that i can show ite detail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道如何使用 DataGrid 来做到这一点,因为我不使用它,但是在 ListBox 中,您可以应用这样的数据模板(删除所有不相关的内容):
这里我假设您在 ListBox 的 DataContext 中为您的命令拥有 MyCommand 属性。
也对 offtop 感到抱歉,但是您的用户真的需要 DataGrid 及其一排愚蠢的类似 excel 的设计吗?这是显示任何数据的最糟糕的方式。也许使用样式良好的 ListBox 更好?开发人员经常使用 DataGrid,因为它可以轻松显示数据库中某个表的内容。但易于显示和易于使用并不是一回事。因此,如果您不需要 DataGrid 的任何额外功能,请使用其他控件。
I don't know exactly how to do it with DataGrid because I don't use it, But in ListBox you can apply data template like this (everything irrelevant removed):
Here I suppose that you have MyCommand property for your command in ListBox's DataContext.
Also sorry for offtop, but are your users really need exactly DataGrid with its all-in-one-row silly excel-like design? This is the worst way to display any data. Maybe it's better to use well-styled ListBox? Often developers use DataGrid because its easy do display a content of some table from database. But easy to display and easy to use are not the same things. So, if you don't need any extra functionality of DataGrid, use other controls.