Gal Ratner
Gal Ratner is a Techie who lives and works in Los Angeles CA and Austin TX. Follow galratner on Twitter Google
Creating free shaped windows in WPF

WPF Allows for transparent windows which can help shape our desktop program to anything we can drew. In a few simple steps we can make a triangular program window. Here is how:

In the main application window, set two values: 

Background="Transparent" AllowsTransparency="True"

Use XAML to draw whatever shape you want your window to be. In our case I chose a triangle surrounded by an ellipse

<Ellipse StrokeThickness="3" Stroke="#FF8F0000" />
    Points="0,200 800,0 800,400"
    StrokeThickness="2" MouseLeftButtonDown="Polygon_MouseLeftButtonDown">
                <SolidColorBrush Color="Blue" Opacity="0.4"/>

All that is left now is to capture and handle MouseLeftButtonDown in order to help drag the window arround the screen.

private void Polygon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

The finished window looks like this:

This looks and feels great and can really enhance user experience.

Posted 28 Aug 2010 1:57 AM by Gal Ratner
Filed under:

Powered by Community Server (Non-Commercial Edition), by Telligent Systems