Skip to content

SyncfusionExamples/how-to-add-icon-on-specific-row-header-of-wpf-datagrid

Repository files navigation

How to Add Icon on Specific Row Header of WPF DataGrid?

This sample illustrated that how to add icon on specific row header of WPF DataGrid (SfDataGrid).

The DataGrid 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.

XAML

<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>

C#

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;
    }
}

DataGrid with icon added to the specifc row header

About

How to add icon on specific row header of WPF DataGrid(SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8

Languages