Tag: navigationservice

是什么决定了NavigationCommands.BrowseBack是否调用了页面构造函数?

我有两个页面,其中有类似的逻辑。 加载页面,单击将显示/隐藏其他按钮的一些按钮,继续下一页。 当我点击下一页时,如果单击后退按钮,我将返回上一页。 不同之处在于,当我单击后退按钮时,一个页面(FirstPage)将调用构造函数,后面的按钮会调用重置默认值。 另一个页面(SecondPage)没有得到调用的构造函数,我不知道为什么。 public FirstPage() { InitializeComponent(); DisplayStuff(); } FirstPage将KeepAlive设置为False 。 public SecondPage(object arg1, object arg2) { InitializeComponent(); DisplayStuff(arg1, arg2); } 此页面还将KeepAlive设置为False 。 这两个页面不会inheritance任何内容,也没有任何内容覆盖任何属性。 我能看到的唯一区别是空构造函数,所以我尝试给SecondPage一个空构造函数,但仍然没有运气。 我对WPF比较新(我每6个月工作一到两个小时),所以我错过了什么? 如果相关,这是后退按钮。 编辑:当我单击后退按钮时,SecondPage不保持其状态。 它只是加载一个空页面,因为还没有调用DisplayStuff 。 导航代码: NavigateTo(new SecondPage(arg1, arg2)); protected void NavigateTo(Page page) { NavigationService.Navigate(page); }

加载页面后立即Windows手机导航

我有2页。(MainPage.xaml,second.xaml)MainPage.xaml是登录页面。 在此页面中,我发送登录名和密码,并收到结果。 我将它们(结果)保存在Isolate Storage中并导航到second.xaml页面; 当我下次启动这个应用程序时,我从Isolate Storage中提取数据,我想立即导航second.xaml,但我不知道如何 我试着写 public MainPage() { InitializeComponent(); //function for Isolate storage InitializeSettings(); NavigationService.Navigate(new Uri(“/Conversation.xaml”, UriKind.Relative)); } 但它不起作用)我明白我无法使用与MainPage()构造函数关联的导航代码。 当然,我可能会做简单的按钮,但我希​​望快速导航 我想可能是它与App.xaml方法有关 private void Application_Launching(object sender, LaunchingEventArgs e) 例如,写我的方法 //function for Isolate storage InitializeSettings(); 有导航吗?(导航在这个例子中不起作用) private void Application_Launching(object sender, LaunchingEventArgs e) { InitializeSettings(); NavigationService.Navigate(new Uri(“/Conversation.xaml”, UriKind.Relative)); } 我可以在哪里使用导航,所以直接进入second.xaml页面,没有完全加载MainPage.xaml(可能没有MainPage.xaml)

如何在同一解决方案中导航到另一个项目

嘿希望有人可以提供帮助。 我在小组中开发了许多不同的项目,我们现在想要将它们结合起来。 因此,我包括了这些项目。 在启动项目中,我包含对其他项目的引用。 然后我使用另一个stackoverflow线程中的代码: 如何导航到另一个项目的视图 这给了我以下几点 NavigationService.Navigate(new Uri(“/MVVMTestApp;/component/View/MainPage.xaml”, UriKind.Relative)); 该项目建立并运行。 但是当我按下应该激活代码的按钮时,在执行该行之后/期间会出现错误。 中断错误位于MainPage.g.cs文件中,如下所示: namespace MVVMTestApp { public partial class MainPage : Microsoft.Phone.Controls.PhoneApplicationPage { internal System.Windows.Controls.TextBlock MainPageTitle; internal System.Windows.Controls.TextBlock LEgE; private bool _contentLoaded; /// /// InitializeComponent /// [System.Diagnostics.DebuggerNonUserCodeAttribute()] public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; *******System.Windows.Application.LoadComponent(this, new System.Uri(“/MVVMTestApp;component/View/MainPage.xaml”, System.UriKind.Relative));** this.MainPageTitle = […]