I have a RadGridView that displays data from my database. I have set up a DataTemplate for the RowDetails:
In order to speed loading of the data, I have implemented the following:
<
DataTemplate
x:Key
=
"ReadRowDetailsTemplate"
>
<
Grid
HorizontalAlignment
=
"Center"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
Label
Content
=
"Alarms for this Read:"
FontSize
=
"14"
FontWeight
=
"Bold"
Grid.Column
=
"0"
Grid.Row
=
"0"
HorizontalAlignment
=
"Center"
/>
<
DataGrid
AlternatingRowBackground
=
"{DynamicResource AlternatingRowBackground}"
AutoGenerateColumns
=
"False"
CanUserResizeColumns
=
"True"
CanUserSortColumns
=
"False"
FontSize
=
"14"
FontWeight
=
"Bold"
Grid.Column
=
"0"
Grid.Row
=
"1"
HorizontalAlignment
=
"Center"
IsReadOnly
=
"True"
ItemsSource
=
"{Binding Path=Alarms, Mode=TwoWay}"
Margin
=
"5"
Name
=
"AlarmsGrid"
ScrollViewer.CanContentScroll
=
"True"
ScrollViewer.HorizontalScrollBarVisibility
=
"Auto"
ScrollViewer.VerticalScrollBarVisibility
=
"Auto"
SelectionChanged
=
"AlarmsGrid_SelectionChanged"
SelectionMode
=
"Single"
SelectionUnit
=
"FullRow"
VerticalAlignment
=
"Top"
>
<
DataGrid.Columns
>
<
DataGridTextColumn
Binding
=
"{Binding Path=AlarmClass}"
Header
=
"Alarm Class"
/>
<
DataGridTextColumn
Binding
=
"{Binding Path=AlarmTime, Converter={StaticResource DateConverter}}"
Header
=
"Time"
Width
=
"150"
/>
<
DataGridTextColumn
Binding
=
"{Binding Path=ListName}"
Header
=
"Source"
/>
<
DataGridTextColumn
Binding
=
"{Binding Path=AlarmStatus}"
Header
=
"Alarm Status"
/>
<
DataGridTextColumn
Binding
=
"{Binding Path=AlarmRejectedReason}"
Header
=
"Reason"
/>
</
DataGrid.Columns
>
</
DataGrid
>
</
Grid
>
</
DataTemplate
>
- I have implemented a class called CustomGridViewToggleRowDetailsColumn which descends from GridViewBoundColumnBase. This class has properties that allow me to hide the GridViewToggleButton for a row if that row does not have any row details. It also has a Click event that is raised whenever the user clicks on the GridViewToggleButton.
- In my class that populates the rows of the RadGridView, I have implemented INotifyPropertyChanged.
- In the window that has the RadGridView, I retrieve my data from the database but leave the Alarms property (which is bound to the DataGrid's ItemsSource property in the DataTemplate) set to null initially. A bool property called HasAlarms is set to true if the row has Alarms associated with it.
- In the window that has the RadGridView, I have a Click event handler for the custom Click event I mentioned in #1. This checks to see if the Alarms property for the row that was clicked is null. If it is, it goes to the database and retrieves the Alarms. Note that this event can't happen unless HasAlarms is set to true for that row.
This is all working, but the DataGrid remains empty after the RowDetails are displayed. What am I missing to make this work?
Tony