Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - how to navighate between XAML pages

 
 
Old 03-23-2007   #1 (permalink)
SenthilVel


 
 

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 SpecsSystem Spec
Old 03-25-2007   #2 (permalink)
Plamen Ratchev


 
 

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 SpecsSystem Spec
Old 04-02-2007   #3 (permalink)
SenthilVel


 
 

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 SpecsSystem Spec
Old 04-03-2007   #4 (permalink)
Plamen Ratchev


 
 

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 SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Is it possible to include XAML files into another XAML file? .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46