Slightly Off Topic - Silverlight UI Design Help

Topics: UI Architecture
Aug 18, 2011 at 5:22 AM
Edited Aug 18, 2011 at 5:37 AM

I have a challenging view that I'm trying to put together and hoped maybe someone has already done something similar or knew of a resource (blog post or something) that could help.  My challenge is that I have a ConductorViewModem/View which uses a ListBox control to show the Items.  This is all setup and dandy.  My ListBoxItem Templates are all set and working and I have a few different templates each matching to a different ChildViewModel/View. 

Now however I have to add a new ChildViewModel that is itself a Conductor and will have a nested ListBox.  Again not that big a deal except I want to size the nested listbox such that the entire parent listItem still displays on the screen.  Basically I don't want two sets of scroll bars that both go off the screen.

On paper I know what to but I'm having issues making it work.  Basically I know that I need to element bind the max height of the child listbox to a % height of the parent listboxitem and then I have to limit the MaxHeight of the parentListBox item to a % of the ViewPort of the Main ListBox.

I've googled for quite a while and found bit and pieces although much references SL2 & SL3.

As an example (assuming 60px for scrollbars and other conent) if the height of my parent list box is 600px I want the maxHeight of the listboxItem to be 540px which means the max height of the nestedChildListBox is 480px. I just need a way to implement that logic dynamically and what elements I need to pull the information from.

I also need something that isn't going to mess up with Virtualizing etc.  Is there a codebehind event I can tack into?  I would love a mvvm solution.

Any thoughts?  thx


Aug 18, 2011 at 9:30 AM

Perhaps you can bind the MaxHeight of each ListBoxItem of the outermost ListBox (using ItemContainerStyle) to the ActualHeight of the ListBox itself.
An IValueConverter could also be useful to add some calculation to the mix.
I'm not sure that this would work at all.
My feeling is that a custom Panel (for the outer ListBox) is the correct way to go, but I'm not familiar with consequences that it could have with ListBox virtualization, and how to overcome them.