views:

324

answers:

1

Hi and happy new year,

I create an object Custom as you can see below

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() { } 
}

I try to bind the custom object on the datagrid object available in silverlight4. I wish to bind any cell on the datagrid. One line should identify by a row object and each cell by a cellCustom.

I use this code

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;

I don't find any explanation on How to custom the binding. Do you have any idea?

Thank you best regards, Alexandre

A: 

I think you can only bind to public properties.

So CellCustom must have a public property to bind to, if that's the object used for the itemsSource, or data context.

jeffo