Creating a Custom WPF ZStackPanel

819 Users read it.
by Victor Gaudioso

Recently I found myself in a position whereby I had to create a WPF UserControl of an image viewer.  The design for the control looked as if you had taken a stack of images and dropped them down onto a surface.  That is, they were not perfectly lined up; some were rotated slightly, some were moved a little to the top, left, bottom or right.   So, I thought about it and decided it would be a good idea to put all of the images into a ListBox Control; however, there was one slight problem: a ListBox Control uses a VirtualizingStackPanel  (VSP) to show it content (also known as Children) and a VSP arranges its Children just like a StackPanel; that is, it lines them up one after the other either vertically or horizontally.  This would not work for what I needed to do and that was, stack the Children in Z-space rather than in x y space.  So, I decided I needed to create a custom Panel that arranges its Children in Z-space, hence I decided to call it a ZStackPanel.  In this article I will show you how to create a custom WPF Panel called a ZStackPanel.  After you have completed this article you will not only have a ZStackPanel but you will have the knowledge you need to create a custom WPF Panel of your own that arranges its Children however you think it should.  Figure 1-0 shows the ZStackPanel in action with WPF Image Controls for children.  So, let's get started.


Figure 1-0: The ZStackPanel in action with WPF Image Controls for children.

User Rating (1 vote)
0 reviews available
$2.79 USD

User Level:Any
Number Of Pages:12

Victor Gaudioso

Victor is a senior application engineer at IdentityMine, a top-tier software company specializing in designing and developing cutting edge software applications, creating customized WPF/Blend and Silverlight training programs and creating tools for designers and developers. Victor has worked with Fortune 500 companies such as Microsoft, Harrah's, Mattel, NBC/Universal, Disney, Best Buy, GameStop, Vivendi Universal Games, and New Line Cinema among others. Victor, a former Flash/ActionScript engineer still stays active in the Flash community by writing articles and tutorials on where he is also a moderator.

See All Postings From Victor Gaudioso >>

Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency