gpt4 book ai didi

c# - WPF窗口中的透明PNG

转载 作者:太空狗 更新时间:2023-10-29 20:59:10 24 4
gpt4 key购买 nike

我尝试将透明的 PNG 图像应用于整个窗口,但窗口始终是白色。

有什么线索可以看出 PNG 的透明度吗?

谢谢!

C#

public SplashScreen()
{
InitializeComponent();

var myBrush = new ImageBrush();
var image = new Image
{
Source = new BitmapImage(
new Uri(
"pack://application:,,,/MyApp;component/Images/Logo.png"))
};
myBrush.ImageSource = image.Source;
Background = myBrush;

}

XAML

<Window x:Class="MyApp.SplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Topmost="True"
Title="SplashScreen" Height="400" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None"
BorderThickness="5" ShowInTaskbar="False" ResizeMode="NoResize" >
<Grid Name="MainGrid">
<Label FontSize="10" Height="20" Foreground="White" Margin="0,0,0,0" Padding="10,0,0,5" Name="statusLabel" VerticalAlignment="Bottom"></Label>
<TextBlock Visibility="Collapsed" FontSize="10" Foreground="White" Margin="18,110,18,30" Name="appInfo" TextAlignment="Center">

</TextBlock>
<TextBlock Visibility="Collapsed" FontSize="20" Foreground="White" Margin="0,83,0,90" Name="version" TextAlignment="Center">

</TextBlock>
</Grid>
</Window>

最佳答案

大量信息 here .我认为您缺少的是窗口上的 AllowsTransparency="True"

关于c# - WPF窗口中的透明PNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12900988/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com