错误“;找不到资源“;在Silverlight导航中

本文关键字:导航 Silverlight 资源 找不到 错误 | 更新日期: 2023-09-27 18:27:18

我有三个页面home.xaml、usermap.xaml和farm.xaml,为此我正试图使用这个在MainPage.xaml中创建一个导航系统

<Grid x:Name="LayoutRoot" Background="White" Style="{StaticResource LayoutRootGridStyle}">
        <Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}">
            <sdk:Frame   x:Name="MainContent" Source="/Home" Style="{StaticResource ContentFrameStyle}"
                         Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">
                <sdk:Frame.UriMapper>
                    <uriMapper:UriMapper>
                        <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
                        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
                    </uriMapper:UriMapper>
                </sdk:Frame.UriMapper>
            </sdk:Frame>
        </Border>
        <Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}">
            <Border x:Name="BrandingBorder" Style="{StaticResource BrandingBorderStyle}">
                <StackPanel x:Name="BrandingStackPanel" Style="{StaticResource BrandingStackPanelStyle}">
                    <ContentControl Style="{StaticResource LogoIcon}"/>
                    <TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" 
                               Text="Jeevan"/>
                </StackPanel>
            </Border>
            <Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}">
                <StackPanel x:Name="LinksStackPanel" Style="{StaticResource LinksStackPanelStyle}">
                    <HyperlinkButton x:Name="Link1" Style="{StaticResource LinkStyle}" 
                                     NavigateUri="/Home" TargetName="ContentFrame" Content="Home"/>
                    <Rectangle x:Name="Divider1" Style="{StaticResource DividerStyle}"/>
                    <HyperlinkButton x:Name="Link2" Style="{StaticResource LinkStyle}" 
                                     NavigateUri="/UserMap" TargetName="ContentFrame" Content="User Map"/>
                    <Rectangle x:Name="Divider3" Style="{StaticResource DividerStyle}"/>
                    <HyperlinkButton x:Name="Link3" Style="{StaticResource LinkStyle}" 
                                     NavigateUri="/Farm" TargetName="ContentFrame" Content="Farm"/>
                </StackPanel>
            </Border>
        </Grid>
    </Grid>

当我试着运行这个。。。它显示Home.xaml页面内容,但当点击任何超链接时,它显示错误。。。

Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. 
Requested URL: /UserMap
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225 

请帮助

感谢

错误“;找不到资源“;在Silverlight导航中

如果您查看代码中的UriMapper:

<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>

您会注意到它正在"/Views/{pageName}.xaml"中查找

"/Views"是您的解决方案中的一个文件夹。

您是否已检查以确保您的其他页面(例如UserMap和Farm)也在该文件夹中?这似乎是你的问题——他们不在那里。