Window Resize and Drag for Borderless Windows

Excerpt from an internal email at EPS/CODE:

CODE Framework now has a feature that makes it easy to make borderless windows that can still be resized and moved around on the screen. For instance, let’s say you make a window like the Word 2013 start screen:

This window has no standard border, but you can actually click anywhere in the window and drag it around with your mouse (although you cannot change the size).

Another example is the main Word app, which also doesn’t use a standard window border or title. But you can still move the window around by grabbing it in the title area, and you can resize it like you would expect:

You can now create the same sort of window in our WPF framework very easily. To do so, create a XAML window declaration like this:

<Window x:Class="CODE.Framework.Wpf.TestBench.CustomBehaviorWindow" 
        xmlns:Controls="clr-namespace:CODE.Framework.Wpf.Controls;assembly=CODE.Framework.Wpf" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="CustomBehaviorWindow"
        Height="300" Width="300"
        MinHeight="50" MinWidth="100"
        WindowStyle="None" ResizeMode="NoResize" 
        Controls:WindowEx.HeaderHeight="26" 
        Controls:WindowEx.AutomaticWindowDragEnabled="True" 
        Controls:WindowEx.AutoWindowMaximizeEnabled="True" 
        Controls:WindowEx.AutoWindowResizingEnabled="True"> 

Note that the WindowStyle is set to None, and ResizeMode (somewhat confusingly) is set to NoResize. This is standard WPF stuff to create a window without a border, which gives you the right look but not the right behavior.

Now we add the new behavior. See the attached properties? Those can be used to turn on various custom behaviors:

Enjoy!