Click here to Skip to main content
15,891,864 members
Articles / Desktop Programming / WPF

A Simple but Useful WPF Container

Rate me:
Please Sign up or sign in to vote.
4.67/5 (6 votes)
2 Dec 2011CPOL2 min read 37.8K   1.6K   12  
Utilize the Grid and GridSplitter to compose a SplitContainer
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Color x:Key ="Color1">#E3EFFF</Color>
    <Color x:Key="Color5">#C0DBFF</Color>

    <!-- GridSplitter Brushes -->
    <LinearGradientBrush x:Key="GridSplitterHorzBackgroundBrush" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Offset="0" Color="{StaticResource Color1}"/>
        <GradientStop Offset="1" Color="{StaticResource Color5}"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="GridSplitterVertBackgroundBrush" EndPoint="0,1" StartPoint="1,1">
        <GradientStop Offset="0" Color="{StaticResource Color5}"/>
        <GradientStop Offset="1" Color="{StaticResource Color1}"/>
    </LinearGradientBrush>

    <!-- Vertical GridSplitter -->
    <Style x:Key="VerticalGridSplitterStyle" TargetType="{x:Type GridSplitter}">
        <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
        <Setter Property="UIElement.Focusable" Value="False"/>
        <Setter Property="ShowsPreview" Value="True"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <!--<Setter Property="ResizeBehavior" Value="PreviousAndNext"/>
        <Setter Property="ResizeDirection" Value="Columns"/>-->
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Width" Value="5"/>
        <Setter Property="Background" Value="{DynamicResource GridSplitterVertBackgroundBrush}"/>
    </Style>

    <!-- Horizontal GridSplitter -->
    <Style x:Key="HorizontalGridSplitterStyle" TargetType="{x:Type GridSplitter}">
        <Setter Property="UIElement.SnapsToDevicePixels" Value="True"/>
        <Setter Property="UIElement.Focusable" Value="False"/>
        <Setter Property="ShowsPreview" Value="True"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <!--<Setter Property="ResizeBehavior" Value="PreviousAndNext"/>
        <Setter Property="ResizeDirection" Value="Rows"/>-->
        <Setter Property="Height" Value="5"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="Background" Value="{DynamicResource GridSplitterHorzBackgroundBrush}"/>
    </Style>


</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions