views:

150

answers:

1

I'm working on an application that contains a number of content areas. I want to implement a behavior such that in response to user input, any of these content areas can be toggled to fit the entire application window, and optionally back to its original position again. I experimented with several approaches and none of them seem optimal for me. Here's what I tried to do:

  1. Use the ClipToBoundsProperty on the content I want to make "Full Screen": Doesn't work because only the CanvasPanel seems to fully respect this property. The application need to be localized so I would really like to avoid the CanvasPanel.
  2. Use a Grid and collapse the other content areas, such that only the one I want to see is visible, hence taking up the entire screen: This will probably work but doesn't seem easy to implement nor maintain. The "Full Screen" content area could be several levels deep, for example residing inside a Tabcontrol, so I would have to hide the tab headers too etc.
  3. Reconstruct the content area in a separate view and display it while hiding the rest: Seems easy enough to do with DataTemplates and my ViewModel objects, but any GUI/View only states are not preserved using this approach.
  4. Somehow "lift" the GUI/View I want to "Full Screen" into the separate view and display it while hiding the rest: I don't know how to do this or even if this is possible.

Anyway if anyone knows a better approach I would love to know about it.

Thanks a lot!

+1  A: 

In regards to your fourth option: You can hide any window by calling "myWindow.Hide()", it will stay in memory, but the user will not be able to see it. Simply call "myWindow.Show()", when you want it displayed again.

Alternatively, you could try using a Popup control, it would be placed over all your other content. See:

http://roecode.wordpress.com/2008/01/07/wpf-popup-control-part-1-the-quick-and-dirty-way/ http://dotnetslackers.com/Community/blogs/bmains/archive/2007/07/26/Introduction-to-WPF-Popups.aspx

viggity
Hi thanks for your reply. I certainly could use a Popup control. But the problem is what to populate the Popup control with. If I simply assign to its content property some existing piece of content, the framework complains that the latter is already in the logical tree and I should remove it first. I don't have any experience manually modifying the logical tree so I'm not even sure if that's a good idea to begin with. If I simply instantiate the content again off my data model objects, then I run into the problem of loosing any GUI states on the original content.
Bojin Li