Bind id field to tag of image inside xceed datagrid

687 Views Asked by At

I want to bind Id field to tag of Image which inside column of Xceed DataGrid.

<xcdg:Column FieldName="D" Title="Delete" Width="50" CellHorizontalContentAlignment="Center" CellVerticalContentAlignment="Center">
    <xcdg:Column.CellContentTemplate>
        <DataTemplate>
            <Image Source="{StaticResource imgDelete}" Tag="{Binding Id}" Width="16" Height="16" Cursor="Hand" 
                   x:Name="imgEdit" MouseLeftButtonUp="imgDelete_MouseLeftButtonUp" ToolTipService.ToolTip="Edit" />
        </DataTemplate>
    </xcdg:Column.CellContentTemplate>
</xcdg:Column>

But in event handler I am getting Tag as null:

private void imgDelete_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    AreaId = Convert.ToInt32((sender as Image).Tag);
    catch (Exception en)
}
1

There are 1 best solutions below

0
On

I solved this as, I put it inside Column definition and then used,