![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | how to navighate between XAML pages hi , can any one let me know on how to navigate between XAML pages? ,,, Senthil http://dotnetcrunch.blogspot.com |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to navighate between XAML pages First, your pages have to be hosted in navigation container: NavigationWindow or Frame. Next, you can use something like this: // navigate to a page instance MyPage next = new MyPage(); this.NavigationService.Navigate(next); // navigate via URI this.NavigationService.Navigate( new Uri("MyPage.xaml", UriKind.Relative)); You can also use hyperlinks or the journal. HTH, Plamen Ratchev http://www.SQLStudio.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: how to navighate between XAML pages Hi , i also used the same method to navigate between pages, but when i hit the ns.Navigate(myPage); i get an error like ": use NEW keyword to create an object instance ".... canu let me know whats the Hotsed in Navigation container?? both of my pages have the build action as Pages.. Thanks Senthil I still get an error like "Plamen Ratchev" <Plamen@SQLStudio.com> wrote in message news:%232Q3rT1bHHA.3408@TK2MSFTNGP03.phx.gbl... > First, your pages have to be hosted in navigation container: > NavigationWindow or Frame. Next, you can use something like this: > > // navigate to a page instance > MyPage next = new MyPage(); > this.NavigationService.Navigate(next); > > // navigate via URI > this.NavigationService.Navigate( new Uri("MyPage.xaml", > UriKind.Relative)); > > You can also use hyperlinks or the journal. > > HTH, > > Plamen Ratchev > http://www.SQLStudio.com > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: how to navighate between XAML pages You must be missing something in your code. Try the following example: // file: App.xaml // Main application. <Application x:Class="NavigationTest.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Container.xaml" > <Application.Resources> </Application.Resources> </Application> // file: Container.xaml // This is the NavigationWinodw that will host your pages. <NavigationWindow x:Class="NavigationTest.Container" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="NavigationTest" Height="300" Width="300" Source="Main.xaml" > </NavigationWindow> // file: Main.xaml // This is the main/default page. <Page x:Class="NavigationTest.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Main" > <Grid> <Button Click ="Next_Click" Content="Next" /> </Grid> </Page> // file: Main.xaml.cs // Code to handle the button click which will navigate to next page. namespace NavigationTest { public partial class Main : System.Windows.Controls.Page { public Main() { InitializeComponent(); } private void Next_Click(object sender, RoutedEventArgs e) { // This is where you create an instance of the next page and navigate to it. NextPage next = new NextPage(); this.NavigationService.Navigate(next); } } } // file: NextPage.xaml // This is the next page that you will navigate to. <Page x:Class="NavigationTest.NextPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="NextPage" > <Grid> <TextBlock>This is the next page.</TextBlock> </Grid> </Page> HTH, Plamen Ratchev http://www.SQLStudio.com |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Is it possible to include XAML files into another XAML file? | .NET General | |||