0

I'm binding a ObservableCollection to a Grid, the class T that I am using would have an structure similar to this:

public class MyObject {
    public int Id {get;set;}
    public string Name {get;set;}
    public Address MyAddress {get;set;}
}

public class Address {
    public String Street {get;set}
}

So I am binding an ObservableCollection to a Telerik RadGridView and, what I want to do, is to display the property Address.Street for each of the elements in the collection but I cannot just figure out how.

I tried to do bindings like the following:

{Binding MyAddress.Street}
{Binding MyAddress/Street}
{Binding Address.Street}

but non of those work. Is there a way to set the Path property of the binding to do such thing?

Thanks in advance!

H.B.
  • 166,899
  • 29
  • 327
  • 400
Hugo
  • 6,244
  • 8
  • 37
  • 43

1 Answers1

1

If you're using GridViewDataColumn with DataMemberBinding, then you might have to use a cell template to render the sub-member properties (I would have thought DataMemberBinding="{Binding Address.Street}" should work, but if it doesn't, well ...):

<telerik:GridViewDataColumn DataMemberBinding="{Binding Address}">
    <telerik:GridViewColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Street}" />
        </DataTemplate>
    </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
McGarnagle
  • 101,349
  • 31
  • 229
  • 260