Nonrectangular Windows

Irregularly shaped windows are often the trademark of cutting-edge consumer applications such as photo editors, movie makers, and MP3 players, and they're likely to be even more common with WPF applications.

Creating a basic shaped window in WPF is easy. However, creating a slick, professional-looking shaped window takes more work—and, most likely, a talented graphic designer to create the outlines and design the background art.

A Simple Shaped Window

The basic technique for creating a shaped window is to follow these steps:

  1. Set the Window.AllowsTransparency property to true.

  2. Set the Window.WindowStyle property to None to hide the nonclient region of the window (the blue border). If you don't, you'll get an InvalidOperationException ...

Get Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.