从突出显示的行返回多个值
我需要从数据网格中突出显示的行返回多个单元格,但遇到了一些困难。
当选择更改时,我将获取所选值:
private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
value = dg.SelectedValue.To_String();
....
}
并且在 XAML 中,它绑定到所选值路径,
<DataGrid SelectedValuePath=somevalue ...
我将如何对行中的多个项目执行此操作。返回的某个值是行中的唯一单元格。
I need to return multiple cells from a highlighted row in a datagrid and am having some difficulties.
When the selection is changes I am grabbing the selected value:
private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
value = dg.SelectedValue.To_String();
....
}
And in the XAML it is bound to the selected value path
<DataGrid SelectedValuePath=somevalue ...
How would I do this for multiple items in the row. The somevalue being returned is a unique cell in the row.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从这里:
基本上它归结为获取选定的行而不是选定的值。
我还建议使用
sender
而不是dg
,因为这样绑定会更松散。即,将sender
转换为dg
类型,然后使用转换结果而不是dg
。From here:
Basically it boils down to getting the selected row rather than the selected value.
I would also suggest using
sender
instead ofdg
since it will be more loosely bound that way. i.e. castsender
to the type ofdg
and then use the result of the cast instead ofdg
.