我有这个Xaml,它在DataGrid中生成一列按钮。问题是图像不显示!我怎么解决这个问题?
<DataGrid.Columns>
<DataGridTextColumn Header="Description" Binding="{Binding Description}" Width="*" />
<DataGridTextColumn Header="Output" Binding="{Binding Output}" Width="*"/>
<DataGridTextColumn Header="Input" Binding="{Binding Input}" Width="*" />
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Click="Add_Button_Click" Visibility="Visible" Height="16" Width="16">
<Image Height="16" Source="/Resources/plus.png" Stretch="Fill" Width="16"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
答案 0 :(得分:1)
添加按钮内容并将图像放入Button.Content
<Button >
<Button.Content>
<Image x:Name="KeyName" Source="pack://Resources/image.png" />
</Button.Content>
</Button>