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(SfDataGrid)?

About the sample

This sample illustrated that 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;
    }
}

IconForRowHeader

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

Requirements to run the demo

Visual Studio 2015 and above versions

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 6

Languages