This project is read-only.


Jan 9, 2013 at 3:38 PM

If I use the CODE Framework WPF MVVM/MVC Application template I automatically get an application with a home screen. The home screen is associated with a HomeController and a Home\StartViewModel. The home screen is not associated with a view in the way that other views are, at least if I understand the framework correctly. It's a shell in which other views can live. This is fine for the majority of applications, where you have a home screen that is basically the site for menus that lead you to views.

But sometimes an application is more focused and should start with a view with things in it (besides menus). For the rest of this discussion assume I'm using Metro, but the discussion might apply to Battleship as well. If I try to accomplish this in App.ApplicationStartup by navigating to "Home", "Start" and then directly to my view (something like Controller.Action("Foo", "Bar")) then I get close to what I want, but the navigation area at the top still allows the user to get back to the Start page, which doesn't really have a reason to exist.

Alternatively, if I skip the "Home", "Start" action nothing displays because there is no shell.

The focused application I have in mind can navigate to child views, but it shouldn't be able to navigate back up the parents all the way to the Start page. So it doesn't seem to be viable to add things to the shell "view" itself, since they would appear on all views, right?

Does anyone have advice on how I can have a populated view be the root of my view tree, rather than the shell? I'm not sure if I'm phrasing my question correctly...

Jan 10, 2013 at 8:33 PM

Each Theme includes its own way of doing menus/navigation. In the Battleship theme for example, you'll notice that your StartViewModel actions are added to a traditional menu and there are no navigation "tabs" at the top of the screen. The framework provides a default "Home" screen for you as part of the Metro theme, which conforms to the way Win RT apps are styled.

You'll notice in HomeController.cs that the Start method returns Shell(... which is a method on the Controller that returns a ShellResult. (If you peek into the source code for the framework, you'll see it's returned to the WindowsShellLauncher class which displays it.) In any case, the home screen is an instance of Shell, which inherits from Window. The appearance of the home screen comes from a resource distionary, named Metro-Shell.xaml which lives in the CODE.Framework.Wpf.Theme.Metro project.

The easiest way to change the appearance of the shell is to download the source code for that project, make a copy the Metro-Shell.xaml file, drop it into the Themes\Metro folder of your project and edit it. You will have to edit Metro.xaml in that same folder to merge your new file. This will override the default look built into the framework. I think this is all you need.

If you DO need to modify the behavior of the Shell (I don't think you do) then the easiest way it is to make your own shell class, inherited from Shell (or download the source code, make your own copy of the Shell...).