【windows phone开发学习笔记】之页面导航 - makang

栏目: 前端 · 发布时间: 9年前

内容简介:【windows phone开发学习笔记】之页面导航 - makang

最近用了一个多月时间终于把看C#看完了(其实之前也看过曾瑛老师的视频教程,无奈看完后基本都忘记差不多了,当时尝试wp开发时非常吃力,只得扔下wp重新学习C#)。再次看完C#,于是又重新开始了学习wp开发。此后,我会把我学习过程中的笔记与大家分享,共同交流和学习。我的微博账号是@ 马and康

页面导航也就是在应用内在的几个页面之间切换,本例是可以从主界面导航到界面1、界面2、当然也支持从界面1、界面2导航到主界面,这是一个很简单的例子,不过无论多复杂的其应用原理跟这也都是一样的。导航主要可以运用两个控件,一个是HyPerLinkButon,还有一个是Button;一般在页面导航中只要通过HyperlinkButton即可,当然你可以根据个人爱好选择自己习惯的控件;

主界面(MainPage)如下:

【windows phone开发学习笔记】之页面导航 - makang

主界面(MainPage)XAML代码如下:

<phone:PhoneApplicationPage
	x:Class="页面导航.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="主界面" 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>

主界面(MainPage)C#主要代码如下;

private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
        }

界面一(Page1)如下;

【windows phone开发学习笔记】之页面导航 - makang

界面二(Page2)如下;

【windows phone开发学习笔记】之页面导航 - makang

至于Page1,Page2的代码就不写出来了,因为其代码跟主界面的HyperlinkButton中的代码类似,可以自行参考MainPage中加红加粗部分;


以上所述就是小编给大家介绍的《【windows phone开发学习笔记】之页面导航 - makang》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Writing Windows VxDs and Device Drivers, Second Edition

Writing Windows VxDs and Device Drivers, Second Edition

Karen Hazzah / CMP / 1996-01-12 / USD 54.95

Software developer and author Karen Hazzah expands her original treatise on device drivers in the second edition of "Writing Windows VxDs and Device Drivers." The book and companion disk include the a......一起来看看 《Writing Windows VxDs and Device Drivers, Second Edition》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具