2010-01-02 42 views
0

我创建一个自定义对象,你可以看到下面绑定自定义对象的Datagrid Silverlight 4中

public class GridViewModel 
{ 
    private List _listRowCust = new List(); 
    public List ListRowCust 
    { 
     get { return _listRowCust; } 
     set { _listRowCust = value; } 
    } 
} 

public class RowCustom 
{ 
    private List<CellCustom> _listCellCustom = new List<CellCustom>(); 
    public List<CellCustom> ListCellCustom 
    { 
    get { return _listCellCustom; } 
    set { _listCellCustom = value; } 
    } 
    public RowCustom() { } 
} 

我尝试绑定在silverlight4可用的DataGrid对象的自定义对象。 我想绑定数据网格上的任何单元格。一行应该由一个行对象和一个cellCustom标识每个单元格。

我使用此代码

textColumn = new DataGridTextColumn(); 
textColumn.Header = "RemainingWork"; 
textColumn.Binding = new Binding("Cell[0]"); //it's a supposed syntax possibility in fact I have 3 rows with 10 cells 
GridElements.Columns.Add(textColumn);     
GridElements.ItemsSource = e.GridViewModel.ListRowCust; 

我没有找到如何定制绑定任何解释。 你有什么想法吗?

谢谢 最好的问候, 亚历山大

+1

该示例不完整。物业叫做“细胞”在哪里?为什么'GridViewModel'不为'ListRowCust'使用'List '? – AnthonyWJones 2010-01-03 18:56:56

回答

0

我想你只能绑定到公共属性。

因此,如果CellCustom是用于itemsSource或数据上下文的对象,则必须拥有要绑定到的公共属性。