Click here to Skip to main content
13,298,655 members (64,426 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


54 bookmarked
Posted 22 Mar 2009

DockPanel Splitter Control for WPF

, 10 Aug 2009
Rate this:
Please Sign up or sign in to vote.
A splitter control for the WPF DockPanel
Sample Image


This control adds size adjustment functionality to elements of a DockPanel in the same way a GridSplitter can adjust the size of columns and rows in a Grid. When resizing the parent container, the elements will be resized proportionally unless the ProportionalResize property is set to False.

Using the Code

Add the OpenSourceControls namespace and add a DockPanelSplitter control after each panel you want to adjust. The DockPanel.Dock attribute controls which edge of the panel the splitter works on.

<Window x:Class="DockPanelSplitterDemo.Window1"




    Title="DockPanelSplitter demo" Height="400" Width="600">
        <Grid Name="LeftPane" DockPanel.Dock="Left" 

                      Width="200" MinWidth="40">
            <Rectangle Fill="LightBlue"/>
        <osc:DockPanelSplitter DockPanel.Dock="Left" Width="4"/>
        <Grid Name="RightPane" DockPanel.Dock="Right" Width="80">
            <Rectangle Fill="Yellow"/>
        <osc:DockPanelSplitter DockPanel.Dock="Right" Width="4"/>
        <Grid Name="TopPane" DockPanel.Dock="Top" 

                     Height="80" MinHeight="20">
            <Rectangle Fill="LightGreen"/>
        <osc:DockPanelSplitter DockPanel.Dock="Top" Height="4"/>
        <Grid Name="BottomPane" DockPanel.Dock="Bottom" Height="70">
            <Rectangle Fill="LightPink"/>
        <osc:DockPanelSplitter DockPanel.Dock="Bottom" Height="4"/>
        <Grid Name="MainPane" Background="Coral" >
            <Rectangle Fill="Coral"/>

The proportional sizing mode can be turned off by setting the ProprtionalResize dependency property to False.

<osc:DockPanelSplitter DockPanel.Dock="Right" Width="4" ProportionalResize="False"/>

Links to Related Projects

  • WpfContrib DockSplitter (cannot find the control in ProportionalResize dependency property to False. Creating resizable panels with splitter bars</a /> (links don't work??)
  • Thumb example

Future Enhancements

  • Use the Thumb control instead of capturing mouse events


  • March 21, 2009 - First post
  • May 25, 2009 - Added proportional resizing
  • August 09, 2009 - Changed to custom control, added template demo, constrained size on client area


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


About the Author

Norway Norway
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralRe: Is ProprtionalResize setting can be set independently for each panel ??? like the dock position (Dock.right for ex.) Pin
Sazuke-kun30-May-09 16:46
memberSazuke-kun30-May-09 16:46 
Generalhi very nice but :) Pin
Sazuke-kun24-May-09 17:53
memberSazuke-kun24-May-09 17:53 
AnswerRe: hi very nice but :) Pin
objo24-May-09 22:08
memberobjo24-May-09 22:08 
GeneralRe: hi very nice but :) Pin
Sazuke-kun25-May-09 7:28
memberSazuke-kun25-May-09 7:28 
cool thx, i really like the fact that now because of your very nice splitter I can almost always use the dockpanel instead of the grid Smile | :)

The XAML is so much cleaner with only DockPanels and in the future i can always change it for a grid if my needs change.

Do you know if Dockpanels add processing overhead versus grid??
GeneralRe: hi very nice but :) Pin
objo25-May-09 13:34
memberobjo25-May-09 13:34 
GeneralRe: hi very nice but :) [modified] Pin
Sazuke-kun25-May-09 13:39
memberSazuke-kun25-May-09 13:39 
GeneralRe: hi very nice but :) Pin
objo25-May-09 13:38
memberobjo25-May-09 13:38 
GeneralRe: hi very nice but :) Pin
Sazuke-kun25-May-09 13:39
memberSazuke-kun25-May-09 13:39 
GeneralRe: hi very nice but :) Pin
Sazuke-kun25-May-09 13:44
memberSazuke-kun25-May-09 13:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 10 Aug 2009
Article Copyright 2009 by objo
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid