Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 28-Oct-11 23:30pm
v4

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
 
Share this answer
 
Comments
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.
Hi.
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.

eg

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

window1(){
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.
 
Share this answer
 
Comments
marinschek 4-Apr-16 5:02am    
Hi,
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900