TopLevelViewLaunchMode and InPlaceExceptPopups

Mar 12, 2013 at 3:36 PM
I want to need to create an application where I need to display more than one view at a time.
I thought the key was to use ViewLevel.Popup and change
<Setter Property="TopLevelViewLaunchMode" Value="InPlaceExceptPopups" />

So in Metro.xaml where I usually merge the resource dictionaries I added
<Style TargetType="{x:Type mvvm:Shell}" x:Key="CODE.Framework.Wpf.Mvvm.Shell-Style">
    <Setter Property="Background" Value="Black" />
    <Setter Property="TopLevelViewLaunchMode" Value="InPlaceExceptPopups" />
    <Setter Property="c:WindowEx.IsBorderless" Value="False" />
    <Setter Property="Template" Value="{DynamicResource CODE.Framework.Wpf.Mvvm.Shell-Template}" />
</Style>
and I added ViewLevel.Popup when creating the view.

that really produced some very strange results. a new window was created but it was totally empty, and the view was displayed as an overlay.

After some more research I Shell-TopLevelWindowStyle and I define it in Metro.xaml
but the only affect was that now the windows had buttons defined by my actions but nothing else and the view was still overlayed.

What am I missing
Coordinator
Mar 20, 2013 at 7:47 PM
that really produced some very strange results.
Yes :-)

Basically, when you create a style for the shell, you either need to define a complete shell style or derive from an existing shell style. The later being much easier, because there is a ton going on in the shell that is important for the fundamental setup of an app. Basically, when the shell is not right, nothing shows up, although everything is in memory. (Take a look at this article for some more info on that: http://www.codemag.com/Article/1211091). In your example above, you would see much more desirable results if you added BasedOn={StaticResource CODE.Framework.Wpf.Mvvm.Shell-Style}, which bases your new style of the same name on the existing style of that name (which is a perfectly fine thing to do in WPF).

Now for your specific question about showing multiple views at the same time: It depends on what kinds of views you want to show. Most views are "normal views" that are just loaded (as opposed to "popup views" which are usually used to do a specific task and close them back down, like selecting a customer from a list... so dialogs, basically). By default, most themes load all the "normal views" into some sort of tab control. (The tab control may then be styled in various ways, as can be seen in the Metro and Battleship and Vapor themes, but they are usually tabs). If you want to show them at the same time, it depends a bit on how you want to do that. For instance, if you want to show them side by side (kind of like a split-screen setup as Visual Studio can do it with multiple code windows side by side), then one could either create a style for the tab control that shows multiple pages at once, or one could use a different items control to host the views differently (potentially with custom layout). If you wanted these views to be in separate windows, then you'd have to launch individual windows, which is a little more involved and could be achieved in a number of ways (which aren't short to explain, so I am going to wait for your answer to see which way you would like to go :-)).

You could of course also flag all views as top-level views, but that would be kind of odd since it is not what you really want logically, and it would probably not be great for the maintainability of the app. But it certainly should work with a style like the one you describe above (except make sure to use the BasedOn setting).

Markus
Mar 21, 2013 at 12:58 AM
Markus,

I do need separate windows. Our application is running on machines with 2 monitors, one is usually rotated to portrait, while the other is regular landscape. In our legacy application, we typically have 4 windows. And though I probably can reduce that to 2, I still need separate windows.
One will be use to code data, while the other is displaying graphics that can be manipulated (zoomed, rotated, deskewed, ....)

thanks for your help

Thierry


------ Original Message ------
Received: 03:48 PM EDT, 03/20/2013
From: "MarkusEgger" <notifications@codeplex.com>
To: steenbt@usa.net
Subject: Re: TopLevelViewLaunchMode and InPlaceExceptPopups [codeframework:436330]


From: MarkusEgger

that really produced some very strange results.
Yes :-)

Basically, when you create a style for the shell, you either need to define a complete shell style or derive from an existing shell style. The later being much easier, because there is a ton going on in the shell that is important for the fundamental setup of an app. Basically, when the shell is not right, nothing shows up, although everything is in memory. (Take a look at this article for some more info on that: http://www.codemag.com/Article/1211091). In your example above, you would see much more desirable results if you added BasedOn={StaticResource CODE.Framework.Wpf.Mvvm.Shell-Style}, which bases your new style of the same name on the existing style of that name (which is a perfectly fine thing to do in WPF).

Now for your specific question about showing multiple views at the same time: It depends on what kinds of views you want to show. Most views are "normal views" that are just loaded (as opposed to "popup views" which are usually used to do a specific task and close them back down, like selecting a customer from a list... so dialogs, basically). By default, most themes load all the "normal views" into some sort of tab control. (The tab control may then be styled in various ways, as can be seen in the Metro and Battleship and Vapor themes, but they are usually tabs). If you want to show them at the same time, it depends a bit on how you want to do that. For instance, if you want to show them side by side (kind of like a split-screen setup as Visual Studio can do it with multiple code windows side by side), then one could either create a style for the tab control that shows multiple pages at once, or one could use a different items control to host the views differently (potentially with custom layout). If you wanted these views to be in separate windows, then you'd have to launch individual windows, which is a little more involved and could be achieved in a number of ways (which aren't short to explain, so I am going to wait for your answer to see which way you would like to go :-)).

You could of course also flag all views as top-level views, but that would be kind of odd since it is not what you really want logically, and it would probably not be great for the maintainability of the app. But it certainly should work with a style like the one you describe above (except make sure to use the BasedOn setting).

Markus