Silverlight导航

设计1个简单的导航页面

1、在MainPage.xaml文件中加入以下结构

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="SilverkightNavigation.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="60*" MaxHeight="60" MinHeight="60"/>
            <RowDefinition/>
        </Grid.RowDefinitions>    
        <StackPanel x:Name="navigation" Grid.Row="0" Background="#FF682F2F" Orientation="Horizontal">
            <HyperlinkButton x:Name="DefaultLink" Content="首页" NavigateUri="/DefaultPage" TargetName="ContentFrame" />   注意:这里的NavigateUri属性中的DefaultPage不要加xaml后缀
            <HyperlinkButton x:Name="AboutLink" Content="关于" NavigateUri="/AboutPage" TargetName="ContentFrame" />
        </StackPanel>
        <StackPanel x:Name="content" Grid.Row="1" Background="#FF83A8D2">
            <sdk:Frame  x:Name="ContentFrame" Source="/DefaultPage" NavigationFailed="ContentFrame_NavigationFailed">     注意:Source属性中的DefaultPage不要加xaml后缀
                <sdk:Frame.UriMapper>
                    <sdk:UriMapper>
                        <sdk:UriMapping Uri="" MappedUri="/Pages/DefaultPage.xaml"></sdk:UriMapping>
                        <sdk:UriMapping Uri="/{pageName}" MappedUri="/Pages/{pageName}.xaml"></sdk:UriMapping>
                    </sdk:UriMapper>
                </sdk:Frame.UriMapper>
            </sdk:Frame>
        </StackPanel>
    </Grid>
</UserControl>

2、创建Pages文件夹,在这个文件夹中添加2个silverlight页

1)DefaultPage.xaml

<navigation:Page x:Class="SilverkightNavigation.Pages.DefaultPage"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="DefaultPage Page">
    <Grid x:Name="LayoutRoot">
        <TextBlock Text="我是default页面"/>
    </Grid>
</navigation:Page>

2)AboutPage.xaml

<navigation:Page x:Class="SilverkightNavigation.Pages.AboutPage"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="AboutPage Page">
    <Grid x:Name="LayoutRoot">
<TextBlock Text="我是About页面"/>
    </Grid>
</navigation:Page>

转载于:https://www.cnblogs.com/matchcolor/archive/2011/04/24/2026151.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值