August 2014 - If anyone wants to cooperate on developing this library further, please send me a message. I believe the library does not need much work, it only needs to be updated to comply with new operation systems.

Version 1.2.1 released See what was fixed and added in version 1.2.1
First bits of version 1.2 released! See what was fixed and added in version 1.2
New version 1.1 was released! See what was fixed and added in version 1.1


Project Description

Problem of the standard Window class provided in WPF is its poor customization. The goal of this project is to provide highly customizable window class for WPF with many options such as hidding caption icons, setting different text in a caption bar of the window and the text displayed in the taskbar, changing standard caption buttons of the window, displaying UIElements in the header, etc.

In the project are two classes you can use, the first one is StandardWindow that, by default, looks same as WPF Window, but is more customizable. The second class is EssentialWindow, where you can set completely new look of the window.

Standard Window

Standard Window (default)

Here is a default Standard Window

StandardDefault.png

<CustomWindow:StandardWindow x:Class="CustomWindowDemo.DemoWindow1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    ContentHeader="Window Header" Title="Taskbar text"
    Height="100" Width="300">
  <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Default Window</TextBlock>
</CustomWindow:StandardWindow>

Standard Window with modified caption buttons

StandardHidden.png

<CustomWindow:StandardWindow x:Class="CustomWindowDemo.DemoWindow2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    ContentHeader="Window Header" Title="Taskbar text"
    MinimizeButtonState="None" MaximizeButtonState="Disabled"
    Height="100" Width="300">
  <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Window buttons hidden or disabled</TextBlock>
</CustomWindow:StandardWindow>

Standard window with extended caption

StandardExtendedHeader.png

<CustomWindow:StandardWindow x:Class="CustomWindowDemo.DemoWindow3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    ContentHeader="Window Header" Title="Taskbar text"
    ContentHeaderHeight="50"
    Height="200" Width="300">
  <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Extended header</TextBlock>
</CustomWindow:StandardWindow>

Standard window where content overlaps the caption bar

This enables drawing e.g. ribbon known from Office 2007

StandardExtendedContent.png

<CustomWindow:StandardWindow x:Class="CustomWindowDemo.DemoWindow4"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    ContentHeader="" Title="Taskbar text"
    ContentWindowExtend="True"
    Height="100" Width="300">
  <StackPanel>
    <Ellipse Width="40" Height="40" Stroke="#6B7B93" 
           HorizontalAlignment="Left" VerticalAlignment="Top">
      <Ellipse.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
          <GradientStop Color="#EDF0F4" Offset="0.2" />
          <GradientStop Color="#93A4C1" Offset="1" />
        </LinearGradientBrush>
      </Ellipse.Fill>
    </Ellipse>
    <TextBlock TextAlignment="Center">Extended content</TextBlock>
  </StackPanel>
</CustomWindow:StandardWindow>

Standard window with Google Chrome like UI

It's simple to implement UI similar to Google Chrome

StandardGoogleChrome.png

<CustomWindow:StandardWindow x:Class="CustomWindowDemo.DemoWindow5"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    Caption="" Title="Taskbar text"
    ContentExtend="True" CaptionHeight="23"
    Height="100" Width="300">
        <TabControl Margin="-1,0,-1,-1">
            <TabItem Header="Home"></TabItem>
            <TabItem Header="Settings"></TabItem>
            <TabItem Header="About"></TabItem>
        </TabControl>
</CustomWindow:StandardWindow>

Essential window

Essential window enables complete customization of the window. Complete customization of WPF window can be done only when AllowsTransparency is set to "True", which causes that the window is software rendered which might be not as fast GPU rendering.

Example of Essential window
Essential.png

using System.Windows.Controls;
using CustomWindow;

namespace CustomWindowDemo
{
    public partial class DemoEssentialWindow : EssentialWindow
    {
        public DemoEssentialWindow()
        {
            InitializeComponent();
        }

        protected override Decorator GetWindowButtonsPlaceholder()
        {
            return WindowButtonsPlaceholder;
        }

        private void Header_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
                this.DragMove();
        }

        private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            if (this.Width + e.HorizontalChange > 10)
                this.Width += e.HorizontalChange;
            if (this.Height + e.VerticalChange > 10)
                this.Height += e.VerticalChange;

        }
    }
}

<CustomWindow:EssentialWindow x:Class="CustomWindowDemo.DemoEssentialWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
    AllowsTransparency="True" Background="Transparent" Title="EssentialWindow"
    Height="300" Width="250">
    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="#3BB2EA">
        <Border BorderBrush="#55FFFFFF" BorderThickness="1" CornerRadius="5">
            <DockPanel Background="#EFF7FA">
                <Border Height="200" MouseMove="Header_MouseMove" DockPanel.Dock="Top">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#3BB2EA" Offset="0" />
                            <GradientStop Color="#EFF7FA" Offset="0.3" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Border Name="WindowButtonsPlaceholder" HorizontalAlignment="Right" VerticalAlignment="Top"
                             Margin="0,-1,10,0" />
                </Border>
                <Thumb DragDelta="Thumb_DragDelta" HorizontalAlignment="Right" DockPanel.Dock="Bottom"
                       Cursor="SizeNWSE" />
                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Essential Window</TextBlock>
            </DockPanel>
        </Border>
    </Border>
</CustomWindow:EssentialWindow>

Changes and fixes in version 1.1



ChangesV11.png

Improvements

  1. Rounded window button corners
  2. 'X' in the close button was improved
  3. Title text color automaticaly changes to white when window is maximized
  4. Code simplifications

Fixed issues

  1. Background property issue - on some computers application crashed when window background was set
  2. Window XP exception - absence of Aero on Windows XP or Windows Server 2003 caused crashes
  3. ContentWindowExtend - designer didn't work when ContentWindowExtend property was used in XAML

Last edited Jul 31 at 10:11 AM by Andysko, version 22