WPF中的图像形状窗口

时间:2013-06-30 15:29:43

标签: c# wpf xaml transparency shape

我想要一个形状像图像的WPF窗口。所以基本上我有一个包含透明度的图像,在透明的地方,我只想通过窗口看到我的桌面。在非透明的地方,我想看到我的形象。与所做的here类似,但是以一种简单易懂的方式(在我链接的示例中,有很多XAML,我不理解一个词)。

1 个答案:

答案 0 :(得分:1)

您在该示例中看到的大部分XAML都与仅显示仅显示图像的窗口无关。其余部分基本上是处理最小化/最大化/关闭按钮。

为了让您入门,下面是您真正需要显示一个只有您的图像的窗口。然后,您可以从此处开始,根据需要添加按钮和内容,使用文章中的示例XAML引导您。

<Window x:Class="CSWPFIrregularShapeWindow.PictureBasedWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="PictureBasedWindow" Height="300" Width="300" Background="Transparent" 
        WindowStyle="None" AllowsTransparency="True" >    
    <Grid>
    <Image Height="250" Name="test" Source="/CSWPFIrregularShapeWindow;component/Images/transparentPic.png" 
        Stretch="Fill" />
    </Grid>
</Window>