Represents a movable and resizable window hosted in WindowPanel.

Namespace: DevZest.Windows
Assembly: DevZest.WpfDocking (in DevZest.WpfDocking.dll)

Syntax

C#
public class WindowControl : ContentControl, 
	IWindow
Visual Basic
Public Class WindowControl _
	Inherits ContentControl _
	Implements IWindow

Remarks

Use Left and Top to specify the location of the window. NaN value results in auto location - the location will be decided by its containing WindowPanel. The containing WindowPanel sets the window's ActualLeft and ActualTop properties.

Use Hotspot attached property to specify the WindowHotspot mouse dragging value for elements in the control template. By default, WindowControl inherits ContentControl's control template which provides no movable or resizable user interface.

Examples

This example demostrates use of WindowPanel and WindowControl (reference to assembly PresentationFramework.Classic.dll required):
CopyXAML
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:dz="http://schemas.devzest.com/presentation"
    xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic"
    WindowState="Maximized">
    <Window.Resources>
        <ControlTemplate x:Key="WindowControlTemplate" TargetType="{x:Type dz:WindowControl}">
            <ControlTemplate.Resources>
                <LinearGradientBrush x:Key="ActiveCaptionBrush" StartPoint="0,0.5" EndPoint="1,0.5">
                    <GradientStop Offset="0" Color="{DynamicResource {x:Static SystemColors.ActiveCaptionColorKey}}" />
                    <GradientStop Offset="1" Color="{DynamicResource {x:Static SystemColors.GradientActiveCaptionColorKey}}" />
                </LinearGradientBrush>
                <LinearGradientBrush x:Key="InactiveCaptionBrush" StartPoint="0,0.5" EndPoint="1,0.5">
                    <GradientStop Offset="0" Color="{DynamicResource {x:Static SystemColors.InactiveCaptionColorKey}}" />
                    <GradientStop Offset="1" Color="{DynamicResource {x:Static SystemColors.GradientInactiveCaptionColorKey}}" />
                </LinearGradientBrush>
            </ControlTemplate.Resources>
            <Grid Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
                <mwt:ClassicBorderDecorator Grid.Column="0" Grid.Row="0" BorderThickness="4">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Rectangle
                            x:Name="CaptionRectangle"
                            Grid.ColumnSpan="2"
                            Height="{x:Static SystemParameters.CaptionHeight}"
                            dz:WindowControl.Hotspot="Move" />
                        <ContentPresenter Grid.Row="1" Grid.ColumnSpan="2"/>
                    </Grid>
                </mwt:ClassicBorderDecorator>
                <Grid FlowDirection="LeftToRight">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="4" />
                        <RowDefinition Height="16" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="16" />
                        <RowDefinition Height="4" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="4" />
                        <ColumnDefinition Width="16" />
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="16" />
                        <ColumnDefinition Width="4" />
                    </Grid.ColumnDefinitions>
                    <Label
                        Background="Transparent"
                        Cursor="SizeNWSE"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        dz:WindowControl.Hotspot="ResizeLeftTop"/>
                    <Label
                        Background="Transparent"
                        Cursor="SizeNS"
                        Grid.Column="2"
                        dz:WindowControl.Hotspot="ResizeTop" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNESW"
                        Grid.Column="3"
                        Grid.ColumnSpan="2"
                        dz:WindowControl.Hotspot="ResizeRightTop" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNESW"
                        Grid.Row="4"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        dz:WindowControl.Hotspot="ResizeLeftBottom"/>
                    <Label
                        Background="Transparent"
                        Cursor="SizeNS"
                        Grid.Row="4"
                        Grid.Column="2"
                        dz:WindowControl.Hotspot="ResizeBottom" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNWSE"
                        Grid.Row="4"
                        Grid.Column="3"
                        Grid.ColumnSpan="2"
                        dz:WindowControl.Hotspot="ResizeRightBottom" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNWSE"
                        Grid.Row="1"
                        dz:WindowControl.Hotspot="ResizeLeftTop" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeWE"
                        Grid.Row="2"
                        dz:WindowControl.Hotspot="ResizeLeft" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNESW"
                        Grid.Row="3"
                        dz:WindowControl.Hotspot="ResizeLeftBottom" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNESW"
                        Grid.Row="1"
                        Grid.Column="4"
                        dz:WindowControl.Hotspot="ResizeRightTop"/>
                    <Label
                        Background="Transparent"
                        Cursor="SizeWE"
                        Grid.Row="2"
                        Grid.Column="4"
                        dz:WindowControl.Hotspot="ResizeRight" />
                    <Label
                        Background="Transparent"
                        Cursor="SizeNWSE"
                        Grid.Row="3"
                        Grid.Column="4"
                        dz:WindowControl.Hotspot="ResizeRightBottom" />
                </Grid>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsKeyboardFocusWithin" Value="True">
                    <Setter Property="Fill" TargetName="CaptionRectangle" Value="{StaticResource ActiveCaptionBrush}" />
                </Trigger>
                <Trigger Property="IsKeyboardFocusWithin" Value="False">
                    <Setter Property="Fill" TargetName="CaptionRectangle" Value="{StaticResource InactiveCaptionBrush}" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <Style TargetType="{x:Type dz:WindowControl}">
            <Setter Property="Template" Value="{StaticResource WindowControlTemplate}" />
        </Style>
    </Window.Resources>
    <dz:WindowPanel>
        <dz:WindowControl Width="300" Height="200">
            <TextBox Text="Window1" />
        </dz:WindowControl>
        <dz:WindowControl Width="300" Height="200">
            <TextBox Text="Window2" />
        </dz:WindowControl>
    </dz:WindowPanel>
</Window>

Inheritance Hierarchy

See Also