How to use your own navigation framework

Modern UI for WPF comes with a built-in page navigation framework. It is easy-to-use and extensible. You are however not required to use the built-in framework, you can roll your own just as easily.

The default ModernWindow control template includes title, menu and back controls to support the page navigation framework. The ModernWindow.Content property is ignored and not rendered at all in the default template. If you choose to use you own navigation framework, you probably want to render your own controls. This can be achieved by using a custom ModernWindow style that is blank and can be filled by setting the ModernWindow.Content.

The empty ModernWindow style is available in the Modern UI assets with resource key BlankWindow.

This is how you would use the style in XAML:

<mui:ModernWindow x:Class="ModernUIApp7.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    Title="MainWindow"
    Style="{StaticResource BlankWindow}">
  <Grid>
    <TextBlock Text="Content goes here" />
  </Grid>
</mui:ModernWindow>
And here's how to create an blank ModernWindow in code:

var wnd = new ModernWindow {
  Style = (Style)App.Current.Resources["BlankWindow"],
  Content = null	 // your content here
};
wnd.Show();

Important: Please note that the ModernWindow ContentSource, MenuGroupLinks, TitleLinks and LogoData properties are no longer used when using the BlankWindow style. Since you're implementing your own navigation framework, you'll need to provide the controls for it yourself.


Last edited Aug 10, 2014 at 7:41 PM by kozw, version 3

Comments

ivanstz Aug 26, 2014 at 9:53 PM 
Hello I am new to WPF and need some help please,
I am getting an error on Style="{StaticResource BlankWindow}" it says "Object reference not set to an instance of an object." but application compiles and works.
How to get rid of that error?

arkyzs Jun 27, 2014 at 7:26 PM 
@killnine EmptyWindow resource is present in assets/modernwindowex

killnine Oct 16, 2013 at 2:07 PM 
@stars361: I am having same problem. Can't find the EmptyWindow resource.... I have App.xml configured as suggested and the xmlns referenced in my window as suggested.

MithunChopda Sep 14, 2013 at 7:20 AM 
I am using the MUI template project and I don't see the standard WPF controls like Window, Page, Resource Dictionary, Flow Document and Page Function in the Add new item section. Is this correct behavior?
How do I use these native controls with MUI template?

MithunChopda Aug 21, 2013 at 7:33 PM 
I am using the MUI template project and I don't see the standard WPF controls like Window, Page, Resource Dictionary, Flow Document and Page Function in the Add new item section. Is this correct behavior?
I am trying to create a Splash screen and I need to hide the controlbox buttons - minimize, maximize, close. How can I do this? I am able to hide the back button by setting ResizeMode to NoResize.

theboyknowsclass Jul 24, 2013 at 6:10 PM 
any tips on how to implement Logo Data or TitleLinks manually once you use the EmptyWindow style?

kozw May 6, 2013 at 3:39 PM 
see http://mui.codeplex.com/workitem/19663

stars361 May 2, 2013 at 5:34 AM 
hi Kozw,

i have tried above snippet but it does not seem to working. "EmptyWindow" style is not present in ModernUI.xaml
could u provide a work around on how to use a Content Property instead of built in page navigation