Simon
Simon

Reputation: 52

Image-Shaped Window in WPF

I want to have a WPF-Window that is shaped like an image. So basically I have an image that contains transparency and at the transparent places I just want to see through the window to my desktop. In the non-transparent places I want to see my image. Similar to what is done here, but in a way that is simple and understandable(in the example I linked there is LOTS of XAML and I don't understand a word).

Upvotes: 0

Views: 1886

Answers (1)

Gjeltema
Gjeltema

Reputation: 4166

Much of the XAML you see in that example is stuff unrelated to just showing a window that only shows the image. The rest of it is basically handling the minimize/maximize/close buttons.

To get you started, the below is all you really need to show a window that just has your image. You can then go from here and add buttons and things as needed, using that example XAML from the article to lead you on.

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

Upvotes: 1

Related Questions