JerryVienna
JerryVienna

Reputation: 122

Show image in WPF DataGridColumn

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!

Upvotes: 2

Views: 1831

Answers (2)

viky
viky

Reputation: 17689

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>

Upvotes: 2

japf
japf

Reputation: 6728

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

Upvotes: 0

Related Questions