您的位置:首页 > 其它

[Net_Ghost] WPF实例教程(6)

2008-10-15 13:39 281 查看
代码所在位置:WPFSamples/Intro/QuickStart5

这个例子没有.cs文件,只有三个XAML文件,实现了在两个页面之间的跳转

MyApp.xaml
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Page1.xaml">
</Application>
程序运行直接显示Page1

Page1.xaml
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Background="LightBlue">
<TextBlock Margin="10,10,10,10">Start Page</TextBlock>
<TextBlock HorizontalAlignment="Left"
Margin="10,10,10,10">
<Hyperlink NavigateUri="Page2.xaml">Go To Page 2</Hyperlink>
</TextBlock>
</StackPanel>
</Page>

Page1,如下图所示



下面这行代码,定义了一个超链接,点击就可以连接到Page2
<Hyperlink NavigateUri="Page2.xaml">Go To Page 2</Hyperlink>

Page2.xaml
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Background="LightGreen">
<TextBlock DockPanel.Dock="Top"
Margin="10,10,10,10">Page 2</TextBlock>
<TextBlock HorizontalAlignment="Left"
Margin="10,10,10,10">
<Hyperlink NavigateUri="Page1.xaml">Go To The Start Page</Hyperlink>
</TextBlock>
</StackPanel>
</Page>

链接到Page2的图片如下图所示:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: