Edit this page

Events

RadGridView control exposes several events regarding the RowDetails:

More about the events that the RadGridView exposes, can be found here.

  • LoadingRowDetails- the LoadingRowDetails event is raised immediately after the FrameworkElement has been loaded from the Row Details DataTemplate. It is raised the very first time the row details are about to be shown. Once this event has been fired, it will never fire again for that row. However, if the row is recycled and then realized, it starts its "life" again, this event will be fired again the first time the details are about to be shown.

The GridViewRowDetailsEventArgs provide access to the FrameworkElement that has been just loaded (DetailsElement) as well as to the respective GridViewRow(Row). Use this event if you want to modify the FrameworkElement in any way before it is displayed.

For example, if you have a RadGridView with the following RowDetailsTemplate:

<telerik:RadGridView x:Name="radGridView"
                LoadingRowDetails="radGridView_LoadingRowDetails">
    <telerik:RadGridView.RowDetailsTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="City: " />
                <TextBlock Text="{Binding City}" />
            </StackPanel>
        </DataTemplate>
    </telerik:RadGridView.RowDetailsTemplate>
    <!--...-->
</telerik:RadGridView>

You can change the StackPanel's Background depending on is the row alternating:

private void radGridView_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e)
{
    StackPanel element = e.DetailsElement as StackPanel;
    if (e.Row.IsAlternating)
    {
        element.Background = new SolidColorBrush(Colors.Black);
    }
    else
    {
        element.Background = new SolidColorBrush(Colors.White);
    }
}
Private Sub radGridView_LoadingRowDetails(ByVal sender As Object, ByVal e As GridViewRowDetailsEventArgs)
    Dim element As StackPanel = TryCast(e.DetailsElement, StackPanel)

    If e.Row.IsAlternating Then
        element.Background = New SolidColorBrush(Colors.Black)
    Else
        element.Background = New SolidColorBrush(Colors.White)
    End If
End Sub
  • UnloadingRowDetails - when the Row Details DataTemplate is modified or deleted, the UnloadingRowDetails event is raised in case you need to perform some cleanup for the old template before the new one is loaded.

  • RowDetailsVisiblityChanged - It is fired each time the row details are shown or hidden, i.e. by selecting or deselecting the row. Via the GridViewRowDetailsEventArgs you could access the just loaded DetailsElement, the respective GridViewRow (Row) as well as the Visibility of the row details.

To manually change the visibility of a row - set its DetailsVisibility property to either Visibility.Collapsed or Visibility.Visible

See Also

Was this article helpful? Yes No

Give article feedback

Tell us how we can improve this article

Dummy