Hellow.
I do Master/Detail hierarchical RadGridView in the following manner. The View is:
<UserControl x:Class="RecordAndPlaybackSession.Views.RecordAndPlaybackSessionView" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:prism="http://prismlibrary.com/" xmlns:commonControls="clr-namespace:CommonWpfControlLibrary;assembly=CommonWpfControlLibrary" prism:ViewModelLocator.AutoWireViewModel="True"> <i:Interaction.Triggers> <!--<OK> dialog--> <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest, Mode=OneWay}"> <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"> <prism:PopupWindowAction.WindowContent> <commonControls:NotificationDialogPopupView/> </prism:PopupWindowAction.WindowContent> <prism:PopupWindowAction.WindowStyle> <Style TargetType="Window"> <Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="SizeToContent" Value="WidthAndHeight"/> </Style> </prism:PopupWindowAction.WindowStyle> </prism:PopupWindowAction> </prism:InteractionRequestTrigger> </i:Interaction.Triggers> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="35" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.Resources> <DataTemplate x:Key="RowDetailsTemplate"> <telerik:RadGridView Name="SavedSesionsGrid" IsReadOnly="True" ItemsSource="{Binding SavedWorkingSesions}" AutoGenerateColumns="False" ShowGroupPanel="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Date}" Header="Session date"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Time_Begin}" Header="Time Begin"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Time_End}" Header="Time End"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Modbus_Transmision_Mode}" Header="MODBUS Transmision Mode"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Brief_Description}" Header="Brief Description" IsReadOnly="False"/> </telerik:RadGridView.Columns> </telerik:RadGridView> </DataTemplate> </Grid.Resources> <telerik:RadGridView Grid.Row="0" Grid.Column="0" Name="DevicesGrid" ItemsSource="{Binding DevicesWithSavedSesions}" AutoGenerateColumns="False" IsReadOnly="True" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSearch="False" CanUserSortColumns="False" IsFilteringAllowed="False" SelectedItem="{Binding SelectedDevice}" RowIndicatorVisibility="Collapsed" RowDetailsTemplate="{StaticResource RowDetailsTemplate}" Margin="5"> <telerik:RadGridView.Columns> <telerik:GridViewToggleRowDetailsColumn/> <telerik:GridViewDataColumn DataMemberBinding="{Binding DisplayedName}" Header="Name"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding SerialNumber}" Header="Serial #/> <telerik:GridViewDataColumn DataMemberBinding="{Binding SelectedBeamsQuantity}" Header="Beams Quantity"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding SelectedInnerDiameter}" Header="Inner Diameter"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyOwnerOfDevice}" Header="Device Owner"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding MountingLocation}" Header="Locality"/> <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsCurrentlyConnected}" Header="Is Connected"> <telerik:GridViewCheckBoxColumn.CellStyle> <Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </telerik:GridViewCheckBoxColumn.CellStyle> </telerik:GridViewCheckBoxColumn> </telerik:RadGridView.Columns> </telerik:RadGridView> <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center"> <telerik:RadButton Height="25" Width="100" Margin="0 0 0 5" Content="Save" ToolTip="Save current sesion." Command="{Binding SaveWorkingSessionCommand}"/> <telerik:RadButton Height="25" Width="100" Margin="10 0 10 5" Content="Stop" ToolTip="Stop saving process of current sesion" Command="{Binding StopSavingOfWorkingSesionCommand}"/> <telerik:RadButton Height="25" Width="100" Margin="10 0 10 5" Content="Play" ToolTip="Play selected saving sesion" Command="{Binding PlaySavedSessionCommand}"/> <telerik:RadButton Height="25" Width="100" Margin="0 0 0 5" Content="Delete" ToolTip="Delete selected saving session" Command="{Binding DeleteSavedSessionCommand}"/> </StackPanel> </Grid></UserControl>In the ViewModel I create (in particular) the folowing property that is bound to SelectedItem of master RadGridView. This is the user-selected device which session must be saved. Please see it below:
#region Properties. . . . . . . . . public object SelectedDevice{ get { return this._selectedDevice; } set { if (this.SetProperty(ref this._selectedDevice, value)) this.SaveWorkingSessionCommand.RaiseCanExecuteChanged(); }}. . . . . . . . . . . . .#endregionAnd also the following properties:
#region Properties . . . . . . . . . . . /// <summary> /// Gets or sets the collection of devices that have saving sessions, and currently conected device. /// </summary> public ObservableCollection<Device> DevicesWithSavedSesions { get { return this._devicesWithSavedSessions; } set { this._devicesWithSavedSessions = value; } } /// <summary> /// Gets or sets the collection of saved working sessions per device. /// </summary> ObservableCollection<DeviceWorkingSession> SavedWorkingSesions { get { return this._savedWorkingSesions;//new ObservableCollection<DeviceWorkingSession>(this.DevicesWithSavedSesions.SelectMany(device => device.SavedWorkingSession)); } set { this.SetProperty(ref this._savedWorkingSesions, value); } } . . . . . . . . . . . #endregionI initialize these properties in constructor of ViewModel:
this.DevicesWithSavedSesions = new RadObservableCollection<Device>();this.SavedWorkingSesions = new RadObservableCollection<DeviceWorkingSession>();And in 'SaveWorkingSesionCommand' I do the following:
// Create instance of record with information about session being saved.DeviceWorkingSession savedSession = new DeviceWorkingSession();// GUID of saved sesion.savedSession.Id = Guid.NewGuid();// Id of device which sesion is saved.savedSession.Devices_Id = GlobalStaticMembers.SharedProfileHeader.Id;// Date of saving of the session.DateTime sessionDateTime = DateTime.Now;savedSession.Date = sessionDateTime.Date;// Time when sesion saving beginssavedSession.Time_Begin = sessionDateTime.TimeOfDay;savedSession.StrTimeBegin = savedSession.Time_Begin.ToString(@"hh\:mm\:ss\:fff");// Transmision mode of MODBUS protocol.savedSession.Modbus_Transmision_Mode = GlobalStaticMembers.ModbusTransmisionMode;// Save session in 'Device' instance (in the manner as it done in your 'ExpandAllRowsDetails' example in your SDK).(this.SelectedDevice as Device).SavedWorkingSession.Add(savedSession);// Save session in collection that is binding source.this.SavedWorkingSesions.Add(savedSession);Below is the definition of SavedWorkingSession from Device class:
public ObservableCollection<DeviceWorkingSession> SavedWorkingSession{ get { if (this._savedWorkingSession == null) this._savedWorkingSession = new ObservableCollection<DeviceWorkingSession>(); return this._savedWorkingSession; }}But I can not see detail records. Please see 'HierarchyMasterDetail.PNG' file attached. If you need more detail, please write me.