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!

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 comment