Silverlight C# - How to get value of row/cell clicked on in DataGrid?

半城伤御伤魂 提交于 2020-01-07 04:22:19

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/4700092/silverlight-c-sharp-how-to-get-value-of-row-cell-clicked-on-in-datagrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!