New to Telerik UI for WPFStart a free 30-day trial

RowDetailsStyleSelector

Updated on Sep 24, 2025

This article illustrates how to conditionally style row details through RadGridView's RowDetailsStyleSelector property.

First, create a new class which inherits the StyleSelector class (which resides in the System.Windows.Controls assembly) and override its SelectStyle method. Based on your conditions you return the proper Style that will be applied to the DetailsPresenter element.

Example 1: The ConditionalStyleSelector class

C#

    public class ConditionalStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            if (item is Club)
            {
                var club = item as Club;
                if (club.StadiumCapacity > 50000)
                {
                    return BigStadiumStyle;
                }
                else
                {
                    return SmallStadiumStyle;
                }
            }

            return base.SelectStyle(item, container);
        }

        public Style BigStadiumStyle { get; set; }
        public Style SmallStadiumStyle { get; set; }
    }

In this case we have two different styles that could be applied:

  • BigStadiumStyle
  • SmallStadiumStyle.

Depending on the underlying data you can select which style to apply.

Next, in the XAML file define the style selector as a resource and set the properties of the BigStadiumStyle and SmallStadiumStyle:

Example 2: Set the different styles for the style selector

XAML
		<Grid.Resources>
            <my:ConditionalStyleSelector x:Key="StadiumCapacityStyleSelector">
                <my:ConditionalStyleSelector.BigStadiumStyle>
                    <Style TargetType="telerik:DetailsPresenter">
                        <Setter Property="Background" Value="Red" />
                        <Setter Property="Foreground" Value="Yellow" />
                    </Style>
                </my:ConditionalStyleSelector.BigStadiumStyle>
                <my:ConditionalStyleSelector.SmallStadiumStyle>
                    <Style TargetType="telerik:DetailsPresenter">
                        <Setter Property="Background" Value="Yellow" />
                        <Setter Property="Foreground" Value="Red" />
                    </Style>
                </my:ConditionalStyleSelector.SmallStadiumStyle>
            </my:ConditionalStyleSelector>
		</Grid.Resources>

The "my:" prefix before StadiumCapacityStyle specifies the mapping for the namespace of the project: xmlns:my="

If you are using our Implicit Styles, you should base the style on the DetailsPresenterStyle.

Finally, set the RowDetailsStyleSelector property of the RadGridView:

Example 3: Set RadGridView's RowDetailsStyleSelector

XAML

	<telerik:RadGridView RowDetailsStyleSelector="{StaticResource StadiumCapacityStyleSelector}" />

And here is the final result:

Figure 1: The row details styled using the RowDetailsStyleSelector property

Telerik WPF DataGrid-rowdetails-styleselector

nother approach for achieving the same result is demonstrated in the WPF Controls Samples under StyleSelectors -> Row Details.

See Also

In this article
See Also
Not finding the help you need?
Contact Support