我想在wpf网格中将图像源设置为模板字段。它是一个删除列。我的代码如下
<my:DataGrid ItemsSource="{Binding}" IsReadOnly="True" CanUserAddRows="false" AutoGenerateColumns="False" Height="258" HorizontalAlignment="Left" Margin="12,0,0,18" Name="grd_list" VerticalAlignment="Bottom" Width="430">
<my:DataGrid.Columns>
<my:DataGridTextColumn Visibility="Hidden" Header="f1" Binding="{Binding f1}"/>
<my:DataGridTextColumn Header="f2" Binding="{Binding f2}"/>
<my:DataGridTextColumn Header="f3" Binding="{Binding f3}"/>
<my:DataGridCheckBoxColumn Header="Active" Binding="{Binding active}"/>
<my:DataGridCheckBoxColumn Header="f4" Binding="{Binding f4}"/>
<my:DataGridTextColumn Header="Date" Binding="{Binding createDate}"/>
<my:DataGridTemplateColumn Header="Delete" CellTemplate="{StaticResource myTemplate}"/>
<my:DataGridTemplateColumn Header="Edit">
<my:DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<Button Name="btn_edt" ToolTip="Edit the row" CommandParameter="{Binding f1}" Click="btn_edt_Click">
<StackPanel>
<Image Source="Images/imgs/edit.png" />
</StackPanel>
</Button>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
</my:DataGrid.Columns>
</my:DataGrid>
我想将图像设置为类似
<my:DataGridTemplateColumn Header="Edit">
<my:DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<Button Name="btn_edt" ToolTip="Edit the row" CommandParameter="{Binding f1}" Click="btn_edt_Click">
<StackPanel>
<Image Source="Images/imgs/edit.png" />
</StackPanel>
</Button>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
如果可能的话,我该怎么做?
提前致谢
Sivajith