Hi, This may be a WPF Databinding question but I think this should be simple.
I have a RadGridView that displays a collection of objects and allows a user to drill down into a subcollection of the databound object. I use the following XAML to define the GridView:
The SelectedItem of the master GridView works great. When a row is selected the SelectedItem is set in my ViewModel. The problem is that the same functionality is not happening in the child GridView. I think I need to define the DataContext on the sub GridView somehow but I am unsure of how to do this. I would like the sub-GridView (child) to set the SelectedProperty property of my ViewModel but it does not work.
Any assistance would be greatly appreciated!
Thanks,
David Sandor
I have a RadGridView that displays a collection of objects and allows a user to drill down into a subcollection of the databound object. I use the following XAML to define the GridView:
| <telerik:RadGridView ItemsSource="{Binding L2SClasses}" ColumnsWidthMode="Fill" telPres:StyleManager.Theme="Vista" CanUserInsertRows="False" CanUserDeleteRows="False" IsReadOnly="True" |
| SelectedItem="{Binding SelectedClass}" AutoGenerateColumns="False" ShowGroupPanel="False" > |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewToggleRowDetailsColumn /> |
| <telerik:GridViewDataColumn Header="Class Name"> |
| <telerik:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <TextBlock Text="{Binding ClassName}" /> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellTemplate> |
| </telerik:GridViewDataColumn> |
| </telerik:RadGridView.Columns> |
| <telerik:RadGridView.RowDetailsTemplate> |
| <DataTemplate> |
| <telerik:RadGridView ItemsSource="{Binding Properties}" CanUserInsertRows="False" CanUserDeleteRows="False" IsReadOnly="True" ColumnsWidthMode="Fill" |
| telPres:StyleManager.Theme="Vista" MaxWidth="600" ShowGroupPanel="False" SelectedItem="{Binding SelectedProperty,Mode=TwoWay}"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewDataColumn Header="Name"> |
| <telerik:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <TextBlock Text="{Binding Name}" /> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellTemplate> |
| </telerik:GridViewDataColumn> |
| <telerik:GridViewDataColumn Header="Type"> |
| <telerik:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <TextBlock Text="{Binding Type}" /> |
| </DataTemplate> |
| </telerik:GridViewDataColumn.CellTemplate> |
| </telerik:GridViewDataColumn> |
| <telerik:GridViewColumn> |
| <telerik:GridViewColumn.CellTemplate> |
| <DataTemplate> |
| <Button Content="Add to Model >>" Name="btnAddToModel" Click="btnAddToModel_Click" /> |
| </DataTemplate> |
| </telerik:GridViewColumn.CellTemplate> |
| </telerik:GridViewColumn> |
| </telerik:RadGridView.Columns> |
| </telerik:RadGridView> |
| </DataTemplate> |
| </telerik:RadGridView.RowDetailsTemplate> |
| </telerik:RadGridView> |
The SelectedItem of the master GridView works great. When a row is selected the SelectedItem is set in my ViewModel. The problem is that the same functionality is not happening in the child GridView. I think I need to define the DataContext on the sub GridView somehow but I am unsure of how to do this. I would like the sub-GridView (child) to set the SelectedProperty property of my ViewModel but it does not work.
Any assistance would be greatly appreciated!
Thanks,
David Sandor