LayeredStackPanel

August 5th, 2007

I inadvertently created this custom panel a month ago. I wanted my objects to be grouped together in a way similar to the way Media Player groups items…or so I thought. My first implementation just had an x and y offset. It also lets you specify the number of items you actually want to show. (This is in the event you bind to a collection with a huge amount of items. Looks silly.)

Today I opened Media Player and saw it doesn’t actually offset the items but rotates them. So I threw in an item rotation property. Of course the panel had already met my original requirements, so adding the rotation aspect was pointless…unless I blogged about it. Maybe somebody else can use it. So here’s some screen shots.

 

As you can see, you can get some pretty interesting layouts. If you think you could make use of this you can download the source from the link at the bottom of this post. (It’s about 1.5 MB because of the images used in the example app.)

I should let you know that the contents of the panel resize to fit available space when the horizontal and vertical offset are used. This is what I needed from the panel. Unfortunately, things aren’t as nice when you apply a rotation value. This is because I used RenderTransform instead of LayoutTransform on the items.

Download Test Application Source Here