Silverlight C# - 如何获取在 DataGrid 中单击的行/单元格的值? [英] Silverlight C# - How to get value of row/cell clicked on in DataGrid?

查看:25
本文介绍了Silverlight C# - 如何获取在 DataGrid 中单击的行/单元格的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要填充数据的 DataGrid,我想将单击的单元格的值复制到一个字符串中.更好的是,我想从行中的特定单元格中复制值,所以如果有办法将整行加载到数组中会更好.

例如,我有几行是这样的:

包含 |关键字 |发生|密度------------------------------------------------是 |KW1 |3 |1.02%是 |关键字2 |1 |0.25%是 |KW1 |3 |1.021%

如果我要单击第 2 行上的任意位置,我希望能够将该行加载到一个数组中,以便我能够调用 gridrow[1] 以始终如一地获得Keyword2"值.

还有:

在较旧的 Silverlights 中,要打开一个新网页,我会使用 HtmlPage.Navigate,但这在 Silverlight 4 中似乎不起作用.(是的,我已经加载了 System.Windows.Browser;)

提前致谢!

-苏塔

解决方案

使用 DataGrid.SelectedItem 属性 获取绑定到所选行的数据.

I've got a DataGrid that I'm populating with data, and I'd like to copy the value of the cell clicked on into a string. Better yet, I'd like to copy the value out of a specific cell in the row, so if there's a way to load the entire row into an array that'd be better.

For instance I'd have a few rows like this:

Included | Keyword     | Occurrences | Density
------------------------------------------------
   Yes   | KW1         |     3       |   1.02%
   Yes   | Keyword2    |     1       |   0.25%
   Yes   | KW1         |     3       |   1.021%

If I were to click anywhere on row 2 I'd like to be able to load the row into an array so that it I'd be able to call gridrow[1] in order to consistently get the value "Keyword2".

Also:

In the older Silverlights, to open up a new webpage I'd use HtmlPage.Navigate, but that doesn't appear to work in Silverlight 4. (Yes, I've loaded System.Windows.Browser; )

Thanks in advance!

-Sootah

解决方案

Use the DataGrid.SelectedItem Property to get the data bound to the selected row.

这篇关于Silverlight C# - 如何获取在 DataGrid 中单击的行/单元格的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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