We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the AlternatingRowStyle to TextBox which is directly loaded into GridTemplateColumn?

Platform: WPF |
Control: SfDataGrid |
Product Version:

SfDataGrid.AlternatingRowStyle property helps you to apply styles for the alternate rows in SfDataGrid. When you set the SfDataGrid.AlternatingRowStyle, the style is not applied to TextBox that is directly loaded into GridTemplateColumn as displayed in the following screenshot.


You can overcome this by setting the TextBox Background as Transparent that is loaded in GridTemplateColumn.

The following code example explains the SfDataGrid is defined with AlternatingRowStyle and GridTemplateColumn is defined with TextBox.


<!--Need to add this code snippet in Resources Define the style with Key-->
<Style x:Key="AlternateRowStyle" TargetType="syncfusion:VirtualizingCellsControl">
      <Setter Property="Background" Value = "LightGray " />
<syncfusion:SfDataGrid Name="SfdataGrid" 
                    AlternatingRowStyle="{StaticResource AlternateRowStyle}"
                    ItemsSource="{Binding Employee}"
        <syncfusion:GridTemplateColumn HeaderText="Employee Name" MappingName="Name" >
                    <TextBox Background="Transparent" Text="{Binding Name}" />


The following screenshot displays the output of SfDataGrid with AlternatingRowStyle. Here, the TextBox is loaded to the Employee name column.


Sample Links,





2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile