我有3页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
请帮忙
由于
答案 0 :(得分:0)
如果你在代码中查看UriMapper:
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
您会注意到它正在查看“/Views/{pageName}.xaml”
“/ Views”是解决方案中的一个文件夹。
您是否检查过以确保您的其他页面(例如UserMap和Farm)也在该文件夹中?这似乎是你的问题 - 他们不在那里。