How to differentiate Frozen/Footer rows and Normal rows in WPF DataGrid?
In the SfDataGrid, you can differentiate the frozen/footer rows and normal rows by customizing the border in the FrozenRow and FooterRow visual states of the VirtualizingCellsControl. In the following code example, the BorderThickness is changed in the FrozenRow and FooterRow visual states.
XAML
<Style TargetType="syncfusion:VirtualizingCellsControl"> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Gray" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="IsTabStop" Value="False" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="syncfusion:VirtualizingCellsControl"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="BorderStates"> <VisualState x:Name="NormalRow" /> <VisualState x:Name="FrozenRow"> <Storyboard BeginTime="0"> <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1" Storyboard.TargetName="PART_RowBorder" Storyboard.TargetProperty="BorderThickness"> <!--Sets the Border Thickness for Frozen Rows-->. <EasingThicknessKeyFrame KeyTime="0" Value="0, 0, 0, 3" /> </ThicknessAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="FooterRow"> <Storyboard BeginTime="0"> <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1" Storyboard.TargetName="PART_RowBorder" Storyboard.TargetProperty="BorderThickness"> <!--Sets the Border Thickness for Footer Rows-->. <EasingThicknessKeyFrame KeyTime="0" Value="0, 3, 0, 0" /> </ThicknessAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames BeginTime="0" Duration="1" Storyboard.TargetName="PART_RowBorder" Storyboard.TargetProperty="Margin"> <EasingThicknessKeyFrame KeyTime="0" Value="0, -1, 0, 0" /> </ThicknessAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Border x:Name="PART_RowBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> </Border> <Rectangle x:Name="PART_CurrentFocusRow" Margin="{TemplateBinding CurrentFocusBorderMargin}" Stroke="DarkGray" StrokeDashArray="2,2" StrokeThickness="1" Visibility="{TemplateBinding CurrentFocusRowVisibility}" /> <Border Background="{TemplateBinding RowHoverBackgroundBrush}" BorderBrush="{TemplateBinding RowHoverBackgroundBrush}" BorderThickness="{TemplateBinding RowHighlightBorderThickness}" Clip="{TemplateBinding HighlightBorderClipRect}" SnapsToDevicePixels="True" Visibility="{TemplateBinding HighlightSelectionBorderVisiblity}" /> <Rectangle Clip="{TemplateBinding RowBackgroundClip}" Fill="{TemplateBinding Background}" /> <Border Background="{TemplateBinding RowSelectionBrush}" Clip="{TemplateBinding SelectionBorderClipRect}" Visibility="{TemplateBinding SelectionBorderVisiblity}" /> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <ContentPresenter /> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
The above code example is for the WPF platform. For other platforms, refer to the following.
Sample Links:
Conclusion
I hope you enjoyed learning about how to differentiate Frozen/Footer rows and Normal rows in DataGrid.
You can refer to our
WPF DataGrid feature tour page to know about its other groundbreaking
feature representations and documentation, and
how to quickly get started for configuration specifications. You can also
explore our WPF
DataGrid example
to
understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!