【发布时间】:2011-05-27 14:40:46
【问题描述】:
在 Silverlight 中,如何从充满数据的 DataGrid 中获取行数据?
我已经走到了这一步(在一个接收按钮点击一行的方法中(:
DataGridRow item = (DataGridRow)dg.SelectedItem;
现在,我如何获取我猜是选定行的项目的各个组件?
在这里帮帮我。如何将 observablecollection 绑定到网格?
在投射到对象时如何使用投射系统?
当我将数据读入网格时,我使用了这个类:
public class Data
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public bool Available { get; set; }
public int index_1 { get; set; }
public int index_2 { get; set; }
public int index_3 { get; set; }
public int index_4 { get; set; }
public int index_5 { get; set; }
public int index_6 { get; set; }
public int index_7 { get; set; }
public int index_8 { get; set; }
public int index_9 { get; set; }
public int index_10 { get; set; }
public int index_11 { get; set; }
public int index_12 { get; set; }
public int index_13 { get; set; }
public int index_14 { get; set; }
public int index_15 { get; set; }
}
所以当我读回时我是如何投射的
这不起作用:
Data _mydata = new Data();
YValue = (_mydata.index_1)dg.SelectedItem;
这不起作用:
YValue = (index_1)dg.SelectedItem;
这不起作用:
YValue = (Data().index_1)dg.SelectedItem;
【问题讨论】: