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 n开发者_如何学JAVAow 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!
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>
You can use a DataGridTemplateColumn to specify your own DataTemplate and render the cell the way you want.
精彩评论