1

I Have a RadGridView. The cell data comes in as MyObject with property ID & Value(Have to display Value). So, List of MyObject forms a row with list of MyObject and List of List of MyObject forms multiple rows. How do I bind the property 'Value' to each cell of each row. Please help. Thank you.

Jeevan
  • 181
  • 1
  • 1
  • 8

2 Answers2

0

Since I have used telerik controls, I am posting a small sample.

XAML:

<Grid.Resources>
    <local:MyViewModel x:Key="MyViewModel" />
</Grid.Resources>

<telerik:RadGridView x:Name="myGridView" DataContext="{StaticResource MyViewModel}" 
                     ItemsSource="{Binding YourList}" 
                     AutoGenerateColumns="False" >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="ID"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" Header="Value"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

In MyViewModel :

public class MyViewModel : BindableBase
{

    private Guid id;
    public Guid Id
    {
        get { return id; }
        set { SetProperty(ref id, value);
    }

    private string yourValue;
    public string Value
    {    
        get { return yourValue;}
        set { SetProperty(ref yourValue, value);    
    }
}
ViVi
  • 4,339
  • 8
  • 29
  • 52
  • Thank you for the response. I resolved the problem with the approach given in http://www.telerik.com/blogs/transpose-or-just-rows-as-columns – Jeevan Jul 25 '16 at 05:37
0

I resolved the problem with the approach given in http://www.telerik.com/blogs/transpose-or-just-rows-as-columns

Rather than trying to bind list of list of objects, transpose the data and feed it to the items source.

Jeevan
  • 181
  • 1
  • 1
  • 8