Our use case is to have a grid which can be expanded to show more granular details including child data, similar to your samples. One of the catches is that not all the data is available in the ItemsSource collection of objects. To avoid what will appear as a memory leak over time, we chose to load / unload the child data as needed. We have success using the RowIsExpandedChanged event to manage the data. We also use the HierarchyChildTemplate and specify the DataTemplate as a collective group of controls and UserControls.
One of these UserControls is another GridView to present a collection of child details of the parent record. This user control will subscribe to events and update its grid with additions and edits. To wire up these events we use an identifier passed to the control via a DependancyProperty. We have found that once a row has been expanded and the UserControl initialized for those events it will remain in effect even when the row is collapsed. To confirm this we wired up the CoerceValueCallback on the DependancyProperty and it is not getting fired when we expand the row after the first time. We understand that due to the virtualization rows are destroyed when out of view. So, in turn, just the event of the user scrolling around will perform a sort of "clean up." As good practice of not leaving resources in use when no longer visible, is there some property we should be setting to destroy the HierarchyChildTemplate when the row is collapsed?
Here are some segments of code we are using.
<Telerik:RadGridView Grid.Row="1" x:Name="radGridViewMain" ItemsSource="{Binding Incidents}"
IsReadOnly="True" AutoGenerateColumns="False" CanUserFreezeColumns="False"
RowIsExpandedChanged="radGridViewMain_RowIsExpandedChanged"
ShowGroupPanel="True" RowIndicatorVisibility="Collapsed"
TelerikGridViewHeaderMenu:GridViewHeaderMenu.IsEnabled="True"
CustomFilter:CustomFilterBehavior.TextBox="{Binding ElementName=textBoxFilter}">
<Telerik:RadGridView.ChildTableDefinitions>
<Telerik:GridViewTableDefinition>
<Telerik:GridViewTableDefinition.Relation>
<TelerikWindowsData:PropertyRelation ParentPropertyName="PrimaryKey"/>
</Telerik:GridViewTableDefinition.Relation>
</Telerik:GridViewTableDefinition>
</Telerik:RadGridView.ChildTableDefinitions>
<Telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<Controls:ChildItems PrimaryKey="{Binding PrimaryKey}" />
For I As Integer = 0 To Me.RadTileView1.Items.Count - 1
Dim item As RadTileViewItem = TryCast(Me.RadTileView1.Items(6), RadTileViewItem)
item.TileState =
TileViewItemState.Maximized
Thread.Sleep(5000)
Next
<telerik:RadChart Grid.Row="1" SeriesMappings="{Binding Path=., Converter={StaticResource WidgetObjToSeriesMappingConverter}}" ItemsSource="{Binding Path=DataSeriesRoot}"/>public class WidgetObjToSeriesMappingConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return null; var seriesMappingCol = new SeriesMappingCollection(); var barChartWidget = (BarChartWidget)value; //Loop through each series, and configure for (int i = 0; i < barChartWidget.DataSeriesRoot.Count; i++) { var seriesMapping = new SeriesMapping(); //Check what type of chart it will be if (value.GetType() == typeof(BarChartWidget)) seriesMapping.SeriesDefinition = new BarSeriesDefinition(); seriesMapping.CollectionIndex = i; seriesMapping.SeriesDefinition.ShowItemLabels = false; seriesMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XCategory)); seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); //Add the series to the collection seriesMappingCol.Add(seriesMapping); } //Return SeriesMapping collection object return seriesMappingCol; } object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }<Window x:Class="GridViewTest.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <ControlTemplate x:Key="DocumentRowTemplate"> <TextBox Text="{Binding MyText}"/> </ControlTemplate> <Style x:Key="DocumentRowStyle" TargetType="{x:Type telerik:GridViewRow}"> <Setter Property="Template" Value="{DynamicResource DocumentRowTemplate}"/> </Style> </Window.Resources> <telerik:RadGridView ItemsSource="{Binding MyEntities}" AutoGenerateColumns="False" RowStyle="{DynamicResource DocumentRowStyle}" CellValidating="RadGridViewCellValidating"/> </Window>