This question is locked. New answers and comments are not allowed.
I have been tring to get my grid to use HierarchyChildTemplate
so I can display child data. From all of the examples I've seen I have the XAML set up correctly however I do believe I don't have the Data setup right.
This is my main data source:
This is the Distribution class:
Does this look right?
I use the following XAML:
here's how I load these classes with data:
I can get the Invoices to show yet no Distributions in the child records, only the header appears.
again, I would like a complete example in VB if possible.
Thanks.
This is my main data source:
Imports SystemImports System.ComponentModelImports System.Collections.ObjectModelPublic Class sosInvoice Implements INotifyPropertyChanged Private _GrossAmount As String Public Property GrossAmount() As String Get Return _GrossAmount End Get Set(ByVal value As String) If _GrossAmount <> value Then _GrossAmount = value NotifyPropertyChanged("GrossAmount") End If End Set End Property Public Distribution As List(Of sosDistribution) Private Sub NotifyPropertyChanged(ByVal PropertyName As String) Dim eNew As New PropertyChangedEventArgs(PropertyName) RaiseEvent PropertyChanged(Me, eNew) End Sub Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChangedEnd ClassThis is the Distribution class:
Imports SystemImports System.ComponentModelImports System.Collections.ObjectModelPublic Class sosDistribution Implements INotifyPropertyChanged Private _Amount As String Public Property Amount() As String Get Return _Amount End Get Set(ByVal value As String) If _Amount <> value Then _Amount = value NotifyPropertyChanged("Amount") End If End Set End Property Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged Private Sub NotifyPropertyChanged(ByVal PropertyName As String) Dim eNew As New PropertyChangedEventArgs(PropertyName) RaiseEvent PropertyChanged(Me, eNew) End SubEnd ClassDoes this look right?
I use the following XAML:
<telerik:RadGridView Name="rgdInvoices" Canvas.Left="12" Canvas.Top="63" Height="478" Width="834" telerik:StyleManager.Theme="Windows7" ItemsSource="{StaticResource sosInvoice}" IsFilteringAllowed="False" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserFreezeColumns="False" FrozenColumnCount="3" CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" ShowInsertRow="False" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" RowLoaded="rgdInvoices_RowLoaded" > <telerik:RadGridView.Columns> <telerik:GridViewDataColumn Header="Gross Amount" DataMemberBinding="{Binding GrossAmount, Mode=TwoWay}" > <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding GrossAmount}" /> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.CellEditTemplate> <DataTemplate> <TextBox Text="{Binding GrossAmount, Mode=TwoWay}" /> </DataTemplate> </telerik:GridViewDataColumn.CellEditTemplate> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> <telerik:RadGridView.HierarchyChildTemplate> <DataTemplate> <telerik:RadGridView BorderThickness="0,1,0,1" telerik:StyleManager.Theme="Windows7" IsFilteringAllowed="False" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserFreezeColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" ShowInsertRow="False" RowIndicatorVisibility="Collapsed" ItemsSource="{Binding Distribution}" AutoGenerateColumns="False" > <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Amount}" Header="Amount" /> </telerik:RadGridView.Columns> </telerik:RadGridView> </DataTemplate> </telerik:RadGridView.HierarchyChildTemplate> <telerik:RadGridView.ChildTableDefinitions> <telerik:GridViewTableDefinition> <telerik:GridViewTableDefinition.Relation> <telerik:PropertyRelation ParentPropertyName="Distribution"/> </telerik:GridViewTableDefinition.Relation> </telerik:GridViewTableDefinition> </telerik:RadGridView.ChildTableDefinitions></telerik:RadGridView>here's how I load these classes with data:
Public Shared g_Invoices As New sosInvoiceList... 'Load data into the collections so it loads with data from here For l_iIndex As Integer = 1 To 20 Dim l_newInvoice As New sosInvoice l_newInvoice.ID = l_iIndex l_newInvoice.GrossAmount = (l_iIndex * 20).ToString l_newInvoice.Distribution = New List(Of sosDistribution) For l_iIndex2 = 1 To 10 Dim l_newDist As New sosDistribution l_newDist.Amount = "99" l_newInvoice.Distribution.Add(l_newDist) Next g_Invoices.Add(l_newInvoice) Next rgdInvoices.ItemsSource = g_InvoicesI can get the Invoices to show yet no Distributions in the child records, only the header appears.
again, I would like a complete example in VB if possible.
Thanks.
