locked
How do navigate one page to another Page ?

    Question

  • Hi,

    How do navigate one page to another Page From MainPage.Xaml.. how do write navigation code in codebehind (xaml.cs)...

     

     

     

    Wednesday, August 18, 2010 8:08 AM

Answers

  • Hi,

    try these

    XAML:

    <navigation:Frame      x:Name="navContent"      HorizontalContentAlignment="Stretch"      VerticalContentAlignment="Stretch"      Source="Welcome">      <navigation:Frame.UriMapper>          <uriMapper:UriMapper>              <uriMapper:UriMapping Uri="Welcome" MappedUri="/Views/Welcome.xaml" />              <uriMapper:UriMapping Uri="Profile" MappedUri="/Views/Profile.xaml" />              <uriMapper:UriMapping Uri="Details/{id}" MappedUri="/Views/Details.xaml?photoid={id}" />          </uriMapper:UriMapper>      </navigation:Frame.UriMapper>  </navigation:Frame> 


    C#

    this.navContent.Navigate(new Uri("Welcome", UriKind.Relative)); 

    Wednesday, August 18, 2010 8:15 AM

All replies

  • Hi,

    try these

    XAML:

    <navigation:Frame      x:Name="navContent"      HorizontalContentAlignment="Stretch"      VerticalContentAlignment="Stretch"      Source="Welcome">      <navigation:Frame.UriMapper>          <uriMapper:UriMapper>              <uriMapper:UriMapping Uri="Welcome" MappedUri="/Views/Welcome.xaml" />              <uriMapper:UriMapping Uri="Profile" MappedUri="/Views/Profile.xaml" />              <uriMapper:UriMapping Uri="Details/{id}" MappedUri="/Views/Details.xaml?photoid={id}" />          </uriMapper:UriMapper>      </navigation:Frame.UriMapper>  </navigation:Frame> 


    C#

    this.navContent.Navigate(new Uri("Welcome", UriKind.Relative)); 

    Wednesday, August 18, 2010 8:15 AM
  • But.. in c# , i can't able to access the name of the navigation:frame 

    Wednesday, August 18, 2010 8:29 AM
  • System.Windows.Controls.Navigation is added in reference and namespace ?

    or

    I think u added navigation inside stackpanel , just remove stack panel and check it

    Wednesday, August 18, 2010 8:45 AM
  • yes .. i am not using stackpanel.. eventhough i can't able to access 

    Wednesday, August 18, 2010 8:51 AM
  • Just Paste your code here........


    Wednesday, August 18, 2010 8:57 AM
  • <UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 

      x:Class="ProjactDetails.MainPage"

      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      xmlns:local="clr-namespace:MenuControl;assembly=MenuControl"

      xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"

      xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"

      xmlns:dataControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"

      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

       

     

      mc:Ignorable="d" d:DesignWidth="1444" d:DesignHeight="481" Loaded="UserControl_Loaded">

        <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}">

          

            <Grid.Background>

                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                    <GradientStop Color="Black" Offset="0" />

                    <GradientStop Color="#14AAA4B4" Offset="1" />

                </LinearGradientBrush>

            </Grid.Background>

            <Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}">

                <navigation:Frame x:Name="NavigationFrame" Style="{StaticResource ContentFrameStyle}"

                                  Source="Project">

                    <navigation:Frame.UriMapper>

                        <uriMapper:UriMapper>

                            <uriMapper:UriMapping Uri="Employee" MappedUri="/Views/EmpList.xaml"/>

    </uriMapper:UriMapper>

     

                    </navigation:Frame.UriMapper>

                </navigation:Frame>

            </Border>

            <Grid Margin="0,62,0,41">

                <Border x:Name="LinksBorder" CornerRadius="10" BorderThickness="4" HorizontalAlignment="Right" Margin="0,30,74,213" Width="250">

                    <local:MenuBar HorizontalAlignment="Center" VerticalAlignment="Center">

                        <local:MenuBarItem MenuText="Project" Background="#FF9962AD">

                            <local:MenuItem MenuText="ProjectList" Click="MenuItem_Click" />

                            <local:MenuItem MenuText="EmployeeList" Click="MenuItem_Click" />

                        </local:MenuBarItem>

                        <local:MenuBarItem MenuText="Task">

                            <local:MenuItem MenuText="Task List" />

                            <local:MenuItem MenuText="Daily Task List" />

                        </local:MenuBarItem>

                    </local:MenuBar>

                </Border>

            </Grid>

            <Border CornerRadius="15" BorderThickness="4" Width="1430" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="7,2,7,0">

                <Border.Background>

                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                        <GradientStop Color="Black" Offset="0" />

                        <GradientStop Color="#FF63A3CB" Offset="1" />

                    </LinearGradientBrush>

                </Border.Background>

                <Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}"  Height="53" Width="1371" HorizontalAlignment="Center">

                  

                        <Grid.RowDefinitions>

                            <RowDefinition Height="18*" />

                            <RowDefinition Height="31*" />

                        </Grid.RowDefinitions>

                    <ContentControl Style="{StaticResource LogoIcon}" Height="50" HorizontalAlignment="Left" VerticalAlignment="Center" Width="133" Grid.RowSpan="2" />

                    <Grid.Background>

                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                            <GradientStop Color="Black" Offset="0" />

                            <GradientStop Color="#FF63A3CB" Offset="1" />

                        </LinearGradientBrush>

                    </Grid.Background>

                </Grid>

            </Border>

         

        </Grid>

     

    </UserControl>

     

    Wednesday, August 18, 2010 9:05 AM
  • Wednesday, August 18, 2010 9:07 AM
  • Thanks.. it's working good 

    Thursday, August 19, 2010 2:05 AM
  • I am searching about navigation from one week, finally i got. Thanks alot...

    Tuesday, December 27, 2011 3:25 AM