简体   繁体   中英

WPF button with transparent background image

I want to create an image button in WPF. So far I have that solution:

<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>

But the problem is that the image I'm using has transparent background, which is shown as white on the button. How I can make it really transparent?

My buttons shows a white background instead of transparent.

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

The image with transparent background should appear transparent by default (without additional settings). I think the problem is in the image (as it was mentioned in the first comment). It looks like the image was saved with a backgound during some transformation in a editor. Give a try to a different PNG (I assume it is a PNG) with the transparent background and see what it gives.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM