tags:

views:

52

answers:

3

Ok I admit, what I need is not a tabpanel, (or is it?). But what I effectively want is a panel with a number of children I can select one of which to be visible at any given time.

Basically I have a couple views and based on the state of the app, the current view needs to change.

This is essentially like Regions from Composite Application Layer, but not plugin-based.

I've tried

  1. Making one visible and another not based on some value
  2. DataTriggers

Have had poor luck getting reliable results from either, and they are hardly discoverable.

Anyone know a good way of approaching this?

A: 

Off the cuff, one approach would be to:

  1. Place each "view" in a named container such as a grid. Set their initial state to "Collapsed"
  2. Maintain an array of all the named containers.
  3. When switching views, set each container's visible state to "Collapsed" (be sure not to use "Hidden"). And then set the visible state to "Visible" of the container you want to be visible.
Metro Smurf
+1  A: 

You could use a ContentPresenter to represent a view and then bind its content to your selected view property.

Admittedly its not a panel, but if used something like a listbox as your collection of views, and then exposed its selected item through a binding. You could use that for the content presenters content.

Val
Interesting approach, might be a bit confusing to a new reader of the xaml though, as the listbox is more of a visual-tree array instead of a visual element. Essentially this would leverage the power of the ItemsControl in listbox and the selection. Interesting none the less...
Aren
+1  A: 

What about using a Screen Conductor?

Read more about the screen conductor here!

rudigrobler
I like this idea a lot, my only qualms being that the views don't seem to be defined in xaml. I suppose I could always extend this idea :)
Aren
Each view is actually a UserControl and completely defined in XAML... The switching in and out happens in code thou!
rudigrobler
Im going to award you the accepted solution. It's not exactly what I solved with, but I ended up basing my solution off the concepts brought forth by the Screen Conductor.
Aren