How to add icon on specific row header of WPF DataGrid (SfDataGrid)?
The WPF DataGrid (SfDataGrid) does not provide the direct support to add an image in RowHeader cells. But you can add an image in the RowHeader cell by customizing the Syncfusion:GridRowHeaderCell.
<Window.Resources> <local:RowHeaderConverter x:Key="rowHeaderConverter"/> <Style TargetType="syncfusion:GridRowHeaderCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="syncfusion:GridRowHeaderCell"> <Border x:Name="PART_RowHeaderCellBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <Grid> <Image Source="{Binding IsLocked, Converter={StaticResource rowHeaderConverter}}" /> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources>
foreach(var record in datagrid.View.Records) { var data = (record as RecordEntry).Data as OrderInfo; if (data.OrderID % 3 == 0) { //To change the image at run time. data.IsLocked = true; } }
View WPF DataGrid Row Header Demo in GitHub
I hope you enjoyed learning about how to add icon on specific row header of WPF DataGrid (SfDataGrid).
You can refer to our WPF Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Grid documentation 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!