Custom Panel Layouts & ItemsControls

I have built a custom panel that arranges its elements in a way that keeps the currently selected element centered. I have been maintaining selection state within the panel so that as the user hits the up or down key the panel calls its ArrangeOverride and updates the centered item.

Up until this point I have been using simple objects for the contents of the panel's InternalChildren collection, such as an Image. Now I would like to use a more complex object, such as an object that consists of an Image and a TextBlock. Furthermore, I would like this complex object to respond to an "IsSelected" trigger so that the TextBlock is either hidden or visible.

I have attempted handle this trigger problem via DataTemplate for my complex object. However, there's nothing in the custom panel to databind a collection of my complex objects to so that the complex objects will make use of the data template. I have also tried using an ItemsControl with the custom panel as the ItemsPanelTemplate, but then I no longer know of a way to for the panel to know which item is selected or how to trigger the ArrangeOverride so that the currently selected item is moved to the center of the screen.

Is what I am attempting to do even possible?

[1263 byte] By [Leebert] at [2007-12-30]

Visual Studio Orcas

Site Classified