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. #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

  3. #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

  4. #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?
Hi, Is it possible to include a XAML file into another XAML file? For example If i have - Window1.xaml - Window2.xaml and both have a...
.NET General
How can i call .xaml Pages through .aspx Page
Hi, I have some Problems . I want to Call .xaml Page from .aspx Pages then how can i do this . And How can i bind the datagrid in my Web Browser...
Avalon
xaml
Please answer me 1. Is XAML maily aiming windows. Why is the controls on double click not produce the event handlers in the c# file( code behind...
Avalon
xaml
Please answer me 1. Is XAML maily aiming windows. Why is the controls on double click not produce the event handlers in the c# file( code behind...
Avalon
launching different XAML aplication from another XAML app
hi , i wanted to know , how i can launch - run , a second xaml application by clicking o n a button from the first XAMl app. see am planning to...
Avalon
How to deploy an XAML-based App with its XAML-UI-File?
Hi, I'm new to WPF/XAML. The basic stuff is working fine, but now I would like to deploy a simple application (C#, but more preferable Visual...
Avalon
File.xaml and File.xaml.cs are atomically checked out/in from sourcesafe
Hi, When I create a WinFX project in Visual Studio, it automatically combines any XAML file with its corresponding .xaml.cs code-behind file,...
Avalon