user2067120
user2067120

Reputation: 267

how to navigate from a wpf window to wpf page in C#(3.0)?

Hey i'm stucked here from last 3 days and tried as hell of possibilities, I have wpf window called 'Mainwindow.xaml' i want to navigate a wpf page named 'addNewTech.xaml' keeping 'Manwindow.xaml' open in background please help me out.. Thank you..

Upvotes: 4

Views: 28852

Answers (2)

Pranali Desai
Pranali Desai

Reputation: 974

 NavigationService navService = NavigationService
 .GetNavigationService(this) 

navService.Navigate =  (new
 System.Uri("Page2.xaml",UriKind.RelativeOrAbsolute); 

OR

 Page2 nextPage = new Page2();

 navService.Navigate(nextPage);

OR

 Page2 page2Obj = new Page2(); //Create object of Page2


 page2Obj.Show(); //Show page2 this.Close(); //this will close Page1

Upvotes: 0

ebattulga
ebattulga

Reputation: 10981

First. Add Frame in MainWindow.

For example:

Use this namespace xmlns:local="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"

<Grid>
   <local:Frame Name="MainFrame" NavigationUIVisibility="Hidden" >                            
   </local:Frame>
</Grid>

call AddNewTech in MainWindow.cs to load page into MainWindow.

MainFrame.Navigate(new Uri("addNewTech.xaml",UriKind.Relative));

Upvotes: 5

Related Questions