Welcome to WindowsClient.net | My Blog | Sign in | Join

Windows Client Videos

Creating Navigation Applications in WPF

There are 2 types of standalone applications in WPF, a standard WPF application which is more like the traditional windows application and a navigation application which is similar in some ways to a web application. A navigation application utilizes a navigation window to move from page to page. This presentation demonstrates how to create a WPF Navigation Application.

Author: Todd Miranda

Posted: Jun 07 2007, 07:53 PM by jaytayl | with 12 comment(s)
Filed under:

Comments

canararaghu said:

Good presentation!!

# September 16, 2008 3:45 PM

SaltyFoam said:

Why do you use the term "navigation application"? Isn't this simply a "wizard" window like in MFC and can't an application contain both "standard" windows and "navigation" windows?

# September 16, 2008 4:15 PM

tmiranda said:

SaltyFoam,

  When WPF first came out we would typically talk about building 3 main types of applications (not including XBAP): Standard apps, Navigation apps, and Gadget apps.  It is really an architectural description more than a technical differentiation.  Yes, you can use navigation windows/panels in a standard windows application.  But you can also build an application that architecturally is a "Navigation" application.  In this case the application itself would rely on "navigating" through the interface using the typical back/forward/history.  You typically don't think of a standard application being driven by navigation elements.  It is usually driven by a typical menu.  Hopefully this helps.

Todd

# September 18, 2008 4:54 PM

megame said:

What would be the best way of adding animations for transitions between pages?

Unlike the other parts of WPF this one looks very tricky to animate - handle navigating event, cancel navigation, animate, do animation?

# November 30, 2008 7:14 PM

tmiranda said:

megame,

  There are a number of ways to do this, a couple of which would be the easiest.  The first is to take a snapshot of the content of the page when navigation initiates.  A new form is displayed (pre-loaded) and the snapshot of the page is placed in this window (the snapshot could be accomplished with something like a visualbrush).  Immediately start the animation fade out. Once the content for the real target page is loaded, just fade that window back in.  So you effectively use a false window to accomplish the fade out while the main window which was hidden when navigation started can be used to fade it in.

  Another way to handle this is not to fade out the entire window but just the content.  So you could put the content in a container that you would fade in and out as navigation proceeded but the window container itself would not fade.

  Lastly, if you use the navigation classes and manually handle the navigation, you could use multiple windows instead of a single window.  In this case, you would easily fade window1 out and window2 in.  Then you could re-use window1 and window2 on the next navigation, swapping back and forth.  This method will require more code and manually handling navigation.  You still get to utilize the power of the navigation classes, but you will just handle all of the UI work manually.

I hope that makes sense and gives you a couple of ideas of what direction to head in.

Todd

# December 3, 2008 2:58 PM

ManjushaN said:

Hello,

1) I have 3 pages.

2) 2nd page has list of records in the Listview grid.When I click on one of the listed records it navigates to page 3.

  I am writing code in the Listview_Selectionchanged event

  NavigationService.Navigate(New Uri("Page3.xaml", UriKind.Relative)

3) I have back button on page3. When I click on the back button , it does goes to page2 ,it then calls the listview_selectionchanged event once again redirecting it back to page 3.And thats how I was getting page 3 again ?

In WPF we can perform Navigation in three main ways: Calling Navigate Method, Hyperlinks and Using Journal

I used Journal method :

If NavigationService.CanGoBack() Then

Me.NavigationService.GoBack()

Else

MessageBox.Show("No entries in back navigation history.")

End If

Can I use Navigate Method (NavigationService.Navigate(New Uri("Page2.xaml", UriKind.Relative))  instead of Journal method in getting the back functionality work ?

Any suggestions?

Thanks for all your help.

-M

# January 7, 2009 10:19 AM

ShadowOfTheBeast said:

when i click on play the media player disappears and nothing happens!

# March 26, 2010 10:42 AM

tombstarship said:

Sounds strange. i have spent hours looking thru text books and the net for a simple solution to this problem. Looked at the source code and got it working in minutes. Well done.

# August 5, 2010 9:37 AM

Siggy13 said:

I am also experiencing the poblem of the media player vanishing when I try to run this video. I run other videos without any problems.

I would be grateful for any suggestions as to how to resolve this problem.

# August 26, 2010 8:25 PM

Lexjon said:

Siggy13, just click on WMV link below "Video Downloads:".

# September 29, 2010 4:53 PM

Andyd273 said:

Just noticed, pages can have Titles, it gets used when you view the page history.

A useful feature for navigation purposes.

# April 26, 2011 2:27 PM

peterkao87 said:

I like this video.  This is my first experiece with WPF Navigation page.  The following are my further experiments:

1. I create an ADO.NET entity data source, and drag  and drop the data in Datagrid form onto  the page. It works. Unlike window, I have to manually write a few C# code Linq to entity.

2. I use static variable to communicate between pages.

3. On a page, I add one button, and add its handlers. It works without surprise.

In the video, I see that it intergrate web pages.

My first impression, this type is one of structure solution. Thanks.

Peter Kao

# October 2, 2011 8:50 AM