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

DataTrigger Defined in CellTemplate of RadGridView Column Doesn't Work.

Updated on Sep 24, 2025

Environment

Product Version2022.3.1109
ProductRadGridView for WPF

Description

A DataTrigger defined in a GridViewColumn's CellTemplate or CellEditTemplate of RadGridView doesn't work.

Solution

Several alternative options can be used instead of DataTrigger. The following trigger definition will serve as a reference on how to replace it with another approach.

DataTrigger definition

XAML
	<telerik:GridViewDataColumn DataMemberBinding="{Binding PersonName}"> 
		<telerik:GridViewDataColumn.CellTemplate> 
			<DataTemplate> 
				<TextBlock x:Name="textBlock" Text="{Binding PersonName}" /> 
				<DataTemplate.Triggers> 
					<DataTrigger Binding="{Binding IsPersonAvailable}" Value="False" > 
						<Setter TargetName="textBlock" Property="Background" Value="Red" /> 
					</DataTrigger> 
				</DataTemplate.Triggers>
			</DataTemplate> 
		</telerik:GridViewDataColumn.CellTemplate> 
	</telerik:GridViewDataColumn> 

Instead, use one of the following ideas:

  • Using a direct data binding for the property targeted by the trigger.

    In that case an additional property in the row's data model should be defined and updated accordingly.

    XAML
    	<telerik:GridViewDataColumn DataMemberBinding="{Binding PersonName}"> 
    		<telerik:GridViewDataColumn.CellTemplate> 
    			<DataTemplate> 
    				<TextBlock x:Name="textBlock" Text="{Binding PersonName}" Background="{Binding PersonBackground}" /> 
    			</DataTemplate> 
    		</telerik:GridViewDataColumn.CellTemplate> 
    	</telerik:GridViewDataColumn> 
  • Using an IValueConverter.

    In that case the converter can return red color if the bound boolean value is false, and black (or other) color when true.

    XAML
    	<telerik:GridViewDataColumn DataMemberBinding="{Binding PersonName}"> 
    		<telerik:GridViewDataColumn.CellTemplate> 
    			<DataTemplate> 
    				<TextBlock x:Name="textBlock" Text="{Binding PersonName}" Background="{Binding IsPersonAvailable, Converter={StaticResource MyBooleanToBrushConverter}}" /> 
    			</DataTemplate> 
    		</telerik:GridViewDataColumn.CellTemplate> 
    	</telerik:GridViewDataColumn> 
  • Using the ContentTemplate of GridViewCell instead of the CellTemplate.

    To utilize this idea, use the CellStyle property of the column.

    XAML
    	<telerik:GridViewDataColumn DataMemberBinding="{Binding PersonName}"> 
    		<telerik:GridViewDataColumn.CellStyle> 
    			<Style TargetType="telerik:GridViewCell">
    				<Setter Property="ContentTemplate">
    					<Setter.Value>
    						<DataTemplate>
    							<TextBlock x:Name="textBlock" Text="{Binding PersonName}" /> 
    							<DataTemplate.Triggers> 
    								<DataTrigger Binding="{Binding IsPersonAvailable}" Value="False" > 
    									<Setter TargetName="textBlock" Property="Background" Value="Red" /> 
    								</DataTrigger> 
    							</DataTemplate.Triggers>
    						</DataTemplate>
    					</Setter.Value>
    				</Setter>
    			</Style>
    		</telerik:GridViewDataColumn.CellTemplate> 
    	</telerik:GridViewDataColumn> 
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support