C# Silverlight 3 - 以编程方式在页面之间导航?
假设我有一个包含多个页面的 C# Silverlight 3 应用程序。第一页称为主页,第二页称为详细信息。导航到详细信息的唯一方法是以编程方式。我该怎么办?到处寻找答案,我发现的只是 xaml uri 映射器实现....
非常感谢帮助
Say I have a C# Silverlight 3 application with a number of pages. The first page is called Home, and the second page is called Details. The only way to navigate to details is programmatically. How do I do this?! Looked everywhere for the answer and all i've found are xaml uri mapper implementations....
Help greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您尝试过导航服务吗?
this.NavigationService.Navigate(new Uri("Details.xaml", UriKind.Relative));
Have you tried the NavigationService?
this.NavigationService.Navigate(new Uri("Details.xaml", UriKind.Relative));
c#:
XAML:
即使你的“详细信息”页面也应该被映射(不管你说什么。)
c#:
XAML:
Even your "details" page should be mapped (despite what you said.)
C#
App.Current.Host.NavigationState = "/欢迎";
XAML
C#
App.Current.Host.NavigationState = "/Welcome";
XAML
最好的解决方案是:
将此代码添加到您的 App.xaml.cs 中:
然后,要在页面之间导航,您只需调用:
The best solution is:
Add this code to your App.xaml.cs:
And then, to navigate between pages, you'll just have to call:
尝试使用这个。这对我有用。
((System.Windows.Controls.Frame)(this.Parent)).Navigate(new Uri("/Import",UriKind.Relative));
Try using this. This worked for me.
((System.Windows.Controls.Frame)(this.Parent)).Navigate(new Uri("/Import",UriKind.Relative));