Hi
I am having difficulty with databinding and child objects with the RadGridview control.
I have a custom object that exposes two properties; a string and a collection (List<>) of child objects. The child objects only expose a single string property.
If I load a number of instances of the custom object each with children, into an Observable collection, the databinding seems to work and I can add new children to the existing parents without any problem.
However, if I add a new parent, when I attempt to add a new child there are databinding errors stating the property name cannot be found and the child is not retained in the child table in the grid control. (BindingExpression path error: 'FloorNo' property not found on 'object' ''Object').
I'm using the MVVM pattern so I am trying to define the hierarchy in the XAML which I've listed below.
Note: Buildings is the observable collection of the custom object Building.
BuildingNo is the string property of Building and Floors is the List<Floor> property where Floor is the child object. FloorNo is the string property of Floor.
Please can you suggest what I need to do to correct or improve the XAML to enable the creation of new children in new parents?
Thanks
Craig
I am having difficulty with databinding and child objects with the RadGridview control.
I have a custom object that exposes two properties; a string and a collection (List<>) of child objects. The child objects only expose a single string property.
If I load a number of instances of the custom object each with children, into an Observable collection, the databinding seems to work and I can add new children to the existing parents without any problem.
However, if I add a new parent, when I attempt to add a new child there are databinding errors stating the property name cannot be found and the child is not retained in the child table in the grid control. (BindingExpression path error: 'FloorNo' property not found on 'object' ''Object').
I'm using the MVVM pattern so I am trying to define the hierarchy in the XAML which I've listed below.
Note: Buildings is the observable collection of the custom object Building.
BuildingNo is the string property of Building and Floors is the List<Floor> property where Floor is the child object. FloorNo is the string property of Floor.
Please can you suggest what I need to do to correct or improve the XAML to enable the creation of new children in new parents?
Thanks
Craig
<telerik:RadGridView HorizontalAlignment="Left" Margin="378,0,0,262" Name="buildingsGridView" VerticalAlignment="Bottom" Width="193" Height="197" ItemsSource="{Binding Buildings, Mode=TwoWay}" AutoGenerateColumns="False" ShowGroupPanel="False" ShowInsertRow="True" RowHeight="23" RowIndicatorVisibility="Collapsed" ScrollViewer.HorizontalScrollBarVisibility="Disabled" CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="True" SelectedItem="{Binding SelectedBuilding}"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding BuildingNo}" Header="Building No." IsFilterable="False" IsGroupable="False" IsReorderable="False" IsResizable="False" ShowDistinctFilters="False" Width="*"/> </telerik:RadGridView.Columns> <telerik:RadGridView.ChildTableDefinitions> <telerik:GridViewTableDefinition> <telerik:GridViewTableDefinition.Relation> <telerik:PropertyRelation ParentPropertyName="Floors" /> </telerik:GridViewTableDefinition.Relation> </telerik:GridViewTableDefinition> </telerik:RadGridView.ChildTableDefinitions> <telerik:RadGridView.HierarchyChildTemplate> <DataTemplate> <telerik:RadGridView ItemsSource="{Binding Floors, Mode=TwoWay}" Name="floorsGrid" ShowGroupPanel="False" AutoGenerateColumns="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding FloorNo}" Header="Floor No." IsFilterable="False" IsGroupable="False" IsReorderable="False" IsResizable="False" ShowDistinctFilters="False" Width="*" /> </telerik:RadGridView.Columns> </telerik:RadGridView> </DataTemplate> </telerik:RadGridView.HierarchyChildTemplate></telerik:RadGridView>