WPF按钮与透明背景图像

时间:2014-04-14 06:00:45

标签: c# .net wpf

我想在WPF中创建一个图像按钮。到目前为止,我有这个解决方案:

<Button Click="btn_Click" Name="btnDelete" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"         Grid.Row="2" Grid.Column="2" BorderBrush="{x:Null}" VerticalContentAlignment="Top" FontSize="15"     FontWeight="Bold" >
    <StackPanel>
         <TextBlock TextAlignment="Center" Name="btnDelete_text" Text="Verwijderen" />
         <Image Stretch="Fill" Name="btnDeleteProductImage" Width="90" Height="90" Source="    {StaticResource delete}" />
    </StackPanel>
</Button>

但问题是我使用的图像具有透明背景,按钮上显示为白色。我怎样才能让它真正透明?

我的按钮显示白色背景而不是透明。

Button, which I hv created. White background is shown, instead of transparency./

2 个答案:

答案 0 :(得分:1)

默认情况下,具有透明背景的图像应显示为透明(无需其他设置)。我认为问题出在图像中(正如第一条评论中提到的那样)。在编辑器中进行某些转换时,看起来图像是使用背景保存的。尝试使用透明背景的不同PNG(我假设它是PNG)并查看它给出的内容。

答案 1 :(得分:0)

PNG格式检查您的图片,我认为即使您的背景透明图片格式不同。

相关问题