Navigation Framework

  看过 Tim Heuer(http://www.silverlight.net/learn/graphics/windows,-screens,-navigation/navigation-framework)的Navigation Framework演示,内容讲的很好,也很深入。值得好好学习。

  我是跟着视频编写代码,运行时,点击跳转页面就会报错。一直以为代码写错了,检测代码,(MainPage.xaml)

<UserControl x:Class="SilverlightAppNavigationStudy.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"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"      
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel  Orientation="Horizontal" VerticalAlignment="Top">
            <StackPanel Orientation="Vertical" Width="250">
                <HyperlinkButton  Click="HyperlinkButton_Click" Content="Home" Tag="Home"></HyperlinkButton>
                <HyperlinkButton  Click="HyperlinkButton_Click" Content="About-Us" Tag="About-Us"></HyperlinkButton>
                <HyperlinkButton  Click="HyperlinkButton_Click" Content="My Customers" Tag="Customers"></HyperlinkButton>
               
            </StackPanel>

            <navigation:Frame x:Name="MainFrame" VerticalContentAlignment="Stretch"
                              HorizontalContentAlignment="Stretch" Margin="20" Source="/Views/HomePage.xaml">

            </navigation:Frame>
        </StackPanel>
    </Grid>

(App.xaml)

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="SilverlightAppNavigationStudy.App"
             xmlns:navcore="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
             >
    <Application.Resources>
        <navcore:UriMapper x:Key="uriMapper">
            <navcore:UriMapping Uri="Home"         MappedUri="/Views/HomePage.xaml"></navcore:UriMapping>
            <navcore:UriMapping Uri="About-Us"     MappedUri="/Views/AboutPage.xaml"></navcore:UriMapping>
            <navcore:UriMapping Uri="Customers"    MappedUri="/Views/CustomersList.xaml"></navcore:UriMapping>
            <navcore:UriMapping Uri="Customer/{id}" MappedUri="/Views/CustomerDetail.xaml?id={id}"></navcore:UriMapping>
        </navcore:UriMapper>
        <navcore:UriMapper x:Key="uriMapper2">
            <navcore:UriMapping Uri="Home"         MappedUri="/Views/HomePage.xaml"></navcore:UriMapping>
       
            <navcore:UriMapping Uri="Customers"    MappedUri="/Views/CustomersList.xaml"></navcore:UriMapping>
            <navcore:UriMapping Uri="Customer/{id}" MappedUri="/Views/CustomerDetail.xaml?id={id}"></navcore:UriMapping>
        </navcore:UriMapper>
    </Application.Resources>
</Application>

搜索,发现有很多网友出现一样的问题,幸好有网友提示 navigation没有加 UriMapper,

回到MainPage,在navigation:Frame x:Name="MainFrame" 后加上 UriMapper="{StaticResource uriMapper}"

重新编译,通过。运行良好。不过有个疑问,Tim Heuer的视频是没有加的,难道还有其他方法?

 

转载于:https://www.cnblogs.com/ITBread/archive/2011/10/20/silverlightNavigation.html

### HarmonyOS Navigation Framework Overview The HarmonyOS navigation framework provides developers with tools and APIs designed specifically for building applications that require robust navigation capabilities. This includes managing routes, transitions between pages, and maintaining stack-based navigation history. In modern application development environments like those supported by Docker images, reliability has been significantly improved compared to previous methods where direct installation on operating systems led to numerous compatibility issues[^1]. For instance, when working within isolated containers or predefined build environments, developers can focus more on functionality rather than underlying system conflicts. For detailed documentation regarding the HarmonyOS navigation framework: - **Official Documentation**: The official Huawei Developer website offers comprehensive guides covering setup instructions, API references, best practices, and sample projects. - **Tutorials**: Various online platforms provide step-by-step tutorials aimed at helping both beginners and experienced programmers understand how to implement effective navigation patterns in HarmonyOS apps. When developing under frameworks such as this one, especially considering multilingual support might be necessary depending on target markets, ensuring adequate language handling is crucial. In cases where specific models may not fully support certain languages, sticking to well-supported ones during initial stages could prove beneficial[^3]. To illustrate basic usage of the navigation component in code form would look something along these lines: ```javascript // Import required modules from @ohos/router package import router from '@ohos/router'; // Define route configurations including paths and corresponding components/pages const routes = [ { path: '/home', component: Home }, { path: '/settings', component: Settings } ]; // Initialize router with defined configuration router.init({ routes }); // Navigate programmatically within your app logic function goToSettings() { router.push('/settings'); } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值