AlternatingRowStyle and RowStyle

Good evening,

in my sfDataGrid i set an alternatingRowStyle and a Row Styel as follow:
AlternatingRowStyle="{StaticResource alternatingRowStyle}" RowStyle="{StaticResource RowStyle}"


 <Style x:Key="alternatingRowStyle" TargetType="Syncfusion:VirtualizingCellsControl">
            <Setter Property="Background" >
                <Setter.Value>
                    <SolidColorBrush Opacity="0.5" Color="#F7F7F7F7" />
                </Setter.Value>
            </Setter>
        </Style>

  <Style x:Key="RowStyle" TargetType="Syncfusion:VirtualizingCellsControl" >
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Annullata}" Value="True">
                    <Setter Property="Background" Value="Tomato"/>
                    <Setter Property="FontStyle" Value="Oblique"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Superata}" Value="True">
                    <Setter Property="Background" Value="SandyBrown"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>


The problem is that if a Row is "colored" by the alternatingRowStyle, it will not "coloured" by the Rowstyle.
It's a problem of priority? I would like to set with higher priority the rowstyle, while at the moment it seems that the alternatingrowstyle has the higher proprity.

thank you in advance,

best regards
Marco Del Frate



3 Replies

SV Srinivasan Vasu Syncfusion Team April 28, 2016 03:26 PM UTC

Hi Marco, 
 
Thanks for contacting Syncfusion support.  
 
We have analyzed your query and you can achieve your requirement by using Style.BasedOn property to apply style for row with higher priority. 
 
Please refer the below code example and we have prepared a sample for this. You can download the same from the below location. 

XAML 
 
 
        <Style x:Key="RowStyle" TargetType="syncfusion:VirtualizingCellsControl" > 
            <Style.Triggers> 
                <DataTrigger Binding="{Binding Path=IsChecked}" Value="True"> 
                    <Setter Property="Background" Value="Yellow"/> 
                    <Setter Property="FontStyle" Value="Oblique"/> 
                </DataTrigger> 
                <DataTrigger Binding="{Binding Path=IsChecked}" Value="False"> 
                    <Setter Property="Background" Value="Red"/> 
                </DataTrigger> 
            </Style.Triggers> 
        </Style> 
        <Style x:Key="alternatingRowStyle" TargetType="syncfusion:VirtualizingCellsControl" BasedOn="{StaticResource RowStyle}" > 
            <Setter Property="Background" > 
                <Setter.Value> 
                    <SolidColorBrush  Opacity="0.5" Color="Green" />                     
                </Setter.Value> 
            </Setter> 
        </Style> 
        
 
 
Regards, 
Srinivasan 
 



BO Boon replied to Srinivasan Vasu February 27, 2026 09:22 PM UTC

If I use the package Syncfusion.Editor.WPF on top the Style doesn't have the property "Background" anymore.


Do I have to target another Style or Control?


Thanks!



SB Sweatha Bharathi Syncfusion Team March 2, 2026 10:19 AM UTC

Boon ,

We have reviewed your query. You encountered an ambiguous type reference exception. This occurs when installing the Syncfusion.Edit.WPF package, the Syncfusion.GridCommon.WPF DLL is added as a dependency, and the VirtualizingCellsControl exists in two DLLs, which leads to the ambiguity issue. To resolve this, explicitly declare the proper namespace by specifying the assembly as shown below. 

Code snippet to resolve ambiguous type reference exception:

<Window x:Class="Samples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Samples"
        xmlns:syncfusion="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="700">
    <Window.DataContext>

For more details, please refer to the Knowledge Base


Find the sample demo in the attachment and let us know if you have any concerns on this.

Attachment: Sample_3e28cc2a.zip

Loader.
Up arrow icon