C# Disciples

my life in Avalon ….

Create Blend like UIs using DOCKY

Docky is a new control for AvalonControlsLibrary. Docky is the codename for this control, the actual name for this control is DockableContainer. Basically Docky is a control that lets you add panels that can be dockable. By Dockable I mean that you can specify where the child panel (control) needs to be docked. If you un dock one of the panels then the panel can be dragged any where on screen (within the working area)

Docky

Using Docky is very similar as using a dockpanel. Like a DockPanel, Docky has an attached property called Dock which you can use to specifiy where you want your panel to be docked. If you do not specify this property Docky will dock your control in the middle ( this is a behavior like Fill). An example for using the Dock property is

< Grid local:DockableContianer.Dock=”Left” ……

Another important thing to know about Docky is how you can make your control be able to Dock and UnDock. Basically there is a command called ToggleDockChild that you can use to Dock and undock your control. This command needs a Parameter which is a reference to the control that is docked. So for example if the panel that is docked is a grid and inside it I have a button that dock and undocks the grid, I would have to pass the instance of the grid as parameter. Let me give an example

<Grid>
<Button Command=”{local:DockableContainer.ToggleDockChild}” CommandParameter=”{Binding RealtiveSource={RelativeSource AncestorType={x;Type Grid}} }”/>
</Grid>

The last thing that one has to do in order to use this control is set the ElementForDragging attached property. This property is used to let the DockableContainer know which control will be used to drag the panel when it is UnDocked. The value of this property should be set as the Panel to drag. You can put this property in any child element of the element being docked because the Docky will analyze the ViusalTree of children of the docked element and check which child has this property set. This is a useful feature for when you need to be able to drag the panel from the Middle part or bottom etc… Again I will give an example

<Grid>
<Button Command=”{local:DockableContainer.ToggleDockChild}” CommandParameter=”{Binding RealtiveSource={RelativeSource AncestorType={x;Type Grid}} }”/>

<Border local:DockableContainer.ElementForDragging=”{Binding RealtiveSource={RelativeSource AncestorType={x;Type Grid}} }“/>
</Grid>

So here what we are saying is that the surface where the user can grab to drag the panel is the Border.

Ok so there is some work to do in order to use this control, so I decided to create a control that handles all this stuff for you. The control is called DockableControl and it inherites from HeaderedContentControl. This control handles all attached properties and commands for the DockableContainer so all you have to do, is to feed the Header and the Content and all the other stuff is catered for.

I created a Demo Project for this control so that you do not need to download AvalonControlsLibrary (well in actual fact I didn’t commit the changes to codeplex yet since I am still doing some refactoring :) ). Download the code for this control and see how it works to get a better idea of how one can use this control…..

If you have any problems, questions or bugs feel free to send me an email at marlongrech@gmail.com or post a comment to this post :)

Hope you like it …

DOWNLOAD DEMO PROJECT

Regards

January 29, 2008 - Posted by marlongrech | .Net 3.0, .Net 3.5, WPF, WPF Custom Controls | | 5 Comments

5 Comments »

  1. I would like to THANK my friend CHAKS for giving this control this cool name DOCKY :)

    Visit Chaks blog at http://chakkaradeep.wordpress.com

    Comment by marlongrech | January 29, 2008 | Reply

  2. Fixed a couple of bugs…
    Bug related to dragging out of screen, now it is disabled.
    Bug related to docking and undocking of controls and after resive container was causing panels to overlap

    Thanks Karl http://karlshifflett.wordpress.com/ for pointing them out and actually helping me to solve them :)

    Comment by marlongrech | January 29, 2008 | Reply

  3. Pleasure to help out. Thanks for DOCKY!

    Cheers,

    Karl

    Comment by Karl Shifflett | January 29, 2008 | Reply

  4. Hey,

    No worries, the control was so cool when you showed to me and thus the name Docky ;)

    And thanks for creating so many useful controls :)

    Comment by Chakkaradeep | January 29, 2008 | Reply

  5. hello it is test. WinRAR provides the full RAR and ZIP file support, can decompress CAB, GZIP, ACE and other archive formats.
    vogwfwsfkxlwfhlpgfcfllwhlfghftujeezhello

    Comment by InhattenePila | January 3, 2009 | Reply


Leave a comment