Recently spent one months to finally see the C # read (in fact, have seen Zeng Ying Teacher's video tutorial, but after reading the basic forgotten almost, when trying to develop WP very laborious, had to drop WP re-learning C #). After reading C # again, I began to learn WP development. After that, I will share with you the notes I have learned in the course of my studies, and communicate and learn together. My Weibo account is @ Horse and Kang ;
Page navigation is also in the application of the internal switch between several pages, this example can be navigated from the main interface to interface 1, Interface 2, and of course support from Interface 1, interface 2 navigation to the main interface, this is a very simple example, but no matter how complex its application principle and this is also the same. Navigation can mainly use two controls, one is Hyperlinkbuton, and the other is a button, generally in the page navigation as long as through the Hyperlinkbutton can, of course, you can choose their own habits according to personal preferences of the control;
The main interface (MainPage) is as follows:
The main interface (MainPage) XAML code is as follows:
<phone:PhoneApplicationPage
x:Class="Page Navigation.MainPage"
Xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
Xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
Xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
Shell: SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Black" >
<StackPanel x:Name="TitlePanel" Grid.Row="0" >
<TextBlock Text="Main interface" FontSize="30" FontFamily="宋"/>
<TextBlock Text="Main Page" FontSize="80" FontFamily="仿宋"/>
<HyperlinkButton Content="Go to Page1" FontSize="30" Foreground="Red" NavigateUri="/Page1.xaml"/>
<HyperlinkButton Content="Go to Page2" FontSize=" 30" Foreground="Red" NavigateUri="/Page2.xaml"/>
<Button Content="Go to Page1" FontSize=" 30" Foreground="Red" Click="Button_Click" />
</StackPanel>
</Grid>
</phone:PhoneApplicationPage>
The main code of the main interface (MainPage) C # is as follows;
private void Button_Click(object sender, RoutedEventArgs e)
{ this.NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
}
Interface One (PAGE1) is as follows;
Interface II (PAGE2) is as follows;
As for the Page1,page2 code is not written out, because its code is similar to the code in the main interface Hyperlinkbutton, you can refer to the red and bold part of the mainpage;
Page navigation for "Windows Phone Development Learning notes"