Click here to Skip to main content
12,813,787 members (32,381 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# WPF
Hello everyone,

I am newbie to this WPF learning out things slowly.

I am stuck with one stuff, my situation is like i have multiple pages i.e page1.xaml,page2.xaml....etc, i have to display these pages in Window1.xaml(wpf window).

This window1.xaml contains a grid (suggest if using other panel is better) which is divided into number of blocks(rows and columns.

The outer blocks of which will be filled with standard template (say some images or with some controls)and one block is assigned to display pages.

Can be assumed similar to codeproject website where the standard codeproject template will be on top irrespective of pages we navigate to.

How can i achieve this displaying of multiple pages in a single window in wpf. Also please help me how to navigate to pages using forward and backward navigation like how we use in browser.

If i use navigationwindow i am not able to use any controls like grid, stackpanle,button.

Thank you
Posted 28-Oct-11 23:41pm
Updated 29-Oct-11 0:30am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at the Frame Class[^] - You'll find information about navigation at the bottom of the page.

Here is a nice example:
WPF Navigation[^] by Paul Stovell.

Best regards
Espen Harlinn
manu g m 29-Oct-11 5:51am
Thank you :)
manu g m 29-Oct-11 5:54am
One more question pls bare with me. How can i navigate to other pages. Ill intilialize to one page on button click, how can i navigate to rest of the pages.
manu g m 29-Oct-11 5:56am
On button click i perform frame1.NavigateService.Navigate(new Page1()); Now how can i navigate to page2.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Navigation can one way be achieved using Galasofts MVVM Framework Messenger. Download package and reference appropriate dll for WPF.

Add add a Frame control in your location within the grid, say FramePages where you want to load pages. You can set default source by specifying page url in the xaml.


In your window1.xaml constructor, register Galasoft's Default messanger as

Messenger.Default.Register<uri>(this, "Window1Navigator", (uri) => this.FramePages.Navigate(uri));

Call from anywhere in the code including in ViewModels Messenger.Default.Send<uri>(UriCreateFromPagePath, "Window1Navigator");

Or withing the pages say NavigationService.Navigate(UriCreateFromPagePath).

I hope this helps. I am open to correction.
marinschek 4-Apr-16 5:02am
I have this problem with frame.
I have two pages A B,and one control C.
in each page I insert the control C.
When I navigate the page was loaded right into frame , but the control when close the preview page was destroied , (for memory leak), and when the second page was loaded the control is disappeared.
let me know

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100