Windows Vista Forums

how to navighate between XAML pages

  1. #1


    SenthilVel Guest

    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

  2.   


  3. #2


    Plamen Ratchev Guest

    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

  4. #3


    SenthilVel Guest

    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

  5. #4


    Plamen Ratchev Guest

    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


how to navighate between XAML pages
Similar Threads
Thread Forum
Is it possible to include XAML files into another XAML file? .NET General
How can i call .xaml Pages through .aspx Page Avalon
launching different XAML aplication from another XAML app Avalon
How to deploy an XAML-based App with its XAML-UI-File? Avalon
File.xaml and File.xaml.cs are atomically checked out/in from sourcesafe Avalon