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" />
<Polygon
Points="0,200 800,0 800,400"
Stroke="Purple"
StrokeThickness="2" MouseLeftButtonDown="Polygon_MouseLeftButtonDown">
<Polygon.Fill>
<SolidColorBrush Color="Blue" Opacity="0.4"/>
</Polygon.Fill>
</Polygon>
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)
{
DragMove();
}
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