views:

62

answers:

2

Hi, I am Binding my wpf DataGrid to an ObservableCollection from code. I am adding the columns by code (as they may change on every report) The UI Deisgner now wants a Column wiht Images for "Delete this row" and "do a special action" on this row. So two Images in one column, and when clicked different behaviour.

Any ideas how to get this done? Thanks in advance!

A: 

You can use a DataGridTemplateColumn to specify your own DataTemplate and render the cell the way you want.

Jalfp
+1  A: 

use this

<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
  <DataTemplate>
    <StackPanel Orientation="Horizontal">
      <Button Click="1st--Handler----here">
        <Image Source="image--path--here"/>
      </Button>
      <Button Click="2nd--Handler----here">
        <Image Source="image--path--here"/>
      </Button>
    <StackPanel>
  </DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
viky