0

我创建了一个自定义对象,如下所示

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;

我没有找到有关如何自定义绑定的任何解释。你有什么主意吗?

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

4

1 回答 1

0

我认为您只能绑定到公共属性。

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

于 2010-10-22T06:32:07.377 回答