Stav Alfi
Stav Alfi

Reputation: 13943

Wpf making a growing transparent window

I would like to make my window be transparent but only a part of the window and not all of it. My goal will be a window that his left side is fully seen and ,slowly, to right side will be seen less and less until the right side is fully transparent.

How do I do it?

Upvotes: 0

Views: 398

Answers (1)

Dmitry
Dmitry

Reputation: 2052

You can easily perform this by setting AllowTransparency and adding an opacity mask on your window. Like this:

<Window x:Class="Testing1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" WindowStyle="None">

       <Window.OpacityMask>
    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
        <GradientStop Color="Black" Offset="0"/>
        <GradientStop Offset="1"/>
    </LinearGradientBrush>
    </Window.OpacityMask>

    <Grid>

    </Grid>

</Window>

Upvotes: 1

Related Questions