Click here to Skip to main content
Rate this: bad
good
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
Edited 29-Oct-11 0:30am
RaisKazi33.5K
v4
Rate this: bad
good
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
  Permalink  
Comments
manu g m at 29-Oct-11 5:51am
   
Thank you :)
manu g m at 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 at 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
good
Please Sign up or sign in to vote.

Solution 2

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 <frame x:name="FramePages" source="../PageViews/DefaulPage.xaml" xmlns:x="#unknown" />

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

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

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

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

I hope this helps. I am open to correction.
  Permalink  

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

  Print Answers RSS
0 Sascha Lefévre 510
1 Sergey Alexandrovich Kryukov 300
2 Abhinav S 255
3 Maciej Los 210
4 Richard Deeming 105
0 Sergey Alexandrovich Kryukov 6,928
1 OriginalGriff 6,381
2 Maciej Los 2,782
3 Abhinav S 2,732
4 Peter Leow 2,694


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2015
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