Silverlight C# - 如何获取 DataGrid 中单击的行/单元格的值?
我有一个正在填充数据的 DataGrid,我想将单击的单元格的值复制到字符串中。更好的是,我想将值从行中的特定单元格复制出来,因此如果有一种方法可以将整行加载到数组中,那就更好了。
例如,我有这样的几行:
Included | Keyword | Occurrences | Density
------------------------------------------------
Yes | KW1 | 3 | 1.02%
Yes | Keyword2 | 1 | 0.25%
Yes | KW1 | 3 | 1.021%
如果我要单击第 2 行上的任意位置,我希望能够将该行加载到数组中,以便我能够在中调用 gridrow[1]为了一致地获取值“Keyword2”。
另外:
在较旧的 Silverlight 中,要打开一个新网页,我会使用 HtmlPage.Navigate,但这在 Silverlight 4 中似乎不起作用。(是的,我已经加载了 System.Windows .浏览器;)
提前致谢!
-苏塔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 DataGrid .SelectedItem 属性 获取绑定到所选行的数据。
Use the DataGrid.SelectedItem Property to get the data bound to the selected row.