【发布时间】:2012-09-12 13:25:00
【问题描述】:
您好,我对 Silverlight 导航应用程序有疑问(使用 Silverlight 4、.NET 4、MS VisualStudio 2010) 我创建了带有 MainPage 和两个页面的导航应用程序 - 主页和关于。 仅修改在首页代码如下。
当我运行项目时,我收到错误“遇到未知错误。请联系您的管理员以获取更多信息。错误详细信息:找不到页面:“/Home”“
怎么了???? :(
Home.xaml
<navigation:Page xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="Nav.Home"
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:DesignWidth="640" d:DesignHeight="480"
Title="Home"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot">
<ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}"></ScrollViewer>
<StackPanel x:Name="ContentStackPanel" Background="{x:Null}" Margin="0,0,0,-28">
<Slider Height="16" Name="sliderVariableCount" Width="300" Minimum="2" Maximum="8" SmallChange="1" ValueChanged="sliderVariableCount_ValueChanged" />
<TextBox Height="53" Name="tbDump" Width="432" />
</StackPanel>
</Grid>
</navigation:Page>
Home.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Nav
{
public partial class Home : Page
{
public Home()
{
InitializeComponent();
}
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void sliderVariableCount_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
tbDump.Text = sliderVariableCount.Value.ToString();
}
}
}
【问题讨论】:
-
发布调用导航服务的代码。我认为您需要使用完整的类名,而不仅仅是 Home,但不能确定,因为 silverlight 导航和 Prism 导航让我束手无策。
-
in MainPage - 默认为链接:
<HyperlinkButton x:Name="Link1" Style="{StaticResource LinkStyle}" NavigateUri="/Home" TargetName="ContentFrame" Content="home"/> -
实际上我假设你的浏览器指向一个类似 localhost/Default.aspx#/Home 的 uri 尝试添加一个斜杠 localhost/Default.aspx#/Home
-
SO 从我的示例 /Home/ 中删除了尾部斜杠
-
URL localhost:5303/NavTestPage.aspx#/About 可以正常工作,但两者(localhost:5303/NavTestPage.aspx#/Home 和 localhost:5303/NavTestPage.aspx)都无法正常工作。我认为当我删除“ValueChanged="sliderVariableCount_ValueChanged"”时滑块问题是可以的