7

ウィンドウ全体に透明な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>
4

2 に答える 2

11

ここにたくさんの情報があります。あなたが欠けている部分はAllowsTransparency="True"あなたの窓にあると思います。

于 2012-10-15T17:38:05.947 に答える
5

私のウィンドウにはデフォルトの背景があり、ウィンドウに Background="Transparent" を設定しないとうまくいきませんでした (おそらく Expression Blend が原因です)。

于 2013-11-06T00:50:45.850 に答える