WPF – Create Irregular (Non-Rectangular) Borderless Windows

With Windows Presentation Foundation (WPF), it’s easy to craft irregular, non-rectangular top-level windows without borders to create a unique splash screen or a gadget-style user interface:

  • Modify the Window Properties
    • Set AllowTransparency property to true.
    • Set WindowStyle to None to remove window chrome
    • Set Background to Transparent
  • Add support for moving and closing the window if needed
    • Use the Window’s DragMove() method to allow users to reposition the Window
    • Add a UI element to allow users to close the window
void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    // DragMove handles all the window placement automatically!
    this.DragMove();
}

  del.icio.us it!

digg it!

reddit!

technorati!

yahoo!

Advertisements

2 responses to “WPF – Create Irregular (Non-Rectangular) Borderless Windows

  1. Thank you so much for this! It solved the problem I was having with no being able to move the transparent window by clicking and dragging the image. Thanks again!

  2. It made my clock superb!
    thanks buddy..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s