删除导航服务上的转发条目?
如何删除导航服务中的所有转发条目?
我尝试过这个,但它崩溃了。
while (NavigationService.CanGoForward) NavigationService.RemoveBackEntry();
我知道“RemoveBackEntry()”看起来很奇怪,但没有RemoveForwardEntry() 方法。
有什么想法吗?
谢谢, Kohan
编辑 1: 我更近了一点,我可以访问前向堆栈,甚至可以输出其中的每个项目,但我似乎无法弄清楚如何删除这些条目。 _frame.ForwardStack 或 j 上的任何属性或方法都没有提供有关如何删除这些条目的任何见解。
Window mainWindow = Application.Current.MainWindow;
Frame _frame = (Frame)mainWindow.FindName("mainFrame");
foreach (JournalEntry j in _frame.ForwardStack)
{
MessageBox.Show(j.Name);
}
How would one remove all the forward entries in a navigation service?
I tried this but it is crashing.
while (NavigationService.CanGoForward) NavigationService.RemoveBackEntry();
I know "RemoveBackEntry()" seems odd but there is no RemoveForwardEntry() method.
Any ideas?
Thanks,
Kohan
Edit 1:
Im a little closer, i can access the forward stack, and even output each item in there but i can not seem to work out how to remove the entries. None of the properties or methods on _frame.ForwardStack or j give any insight into how to remove these entries.
Window mainWindow = Application.Current.MainWindow;
Frame _frame = (Frame)mainWindow.FindName("mainFrame");
foreach (JournalEntry j in _frame.ForwardStack)
{
MessageBox.Show(j.Name);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,答案永远不会太晚!
以下代码将简单地禁用向前导航:
目前它用于 Frame.Navigating 事件,但它应该适用于
Application
以及NavigationWindow
(但未测试) 。编辑:
这是
框架
的行为
:Well, it's never too late for an answer !
The following piece of code will simply disable forward navigation:
Currently it is for the Frame.Navigating event but it should apply for
Application
as well asNavigationWindow
(did not test though).EDIT:
Here is a
Behavior
for aFrame
:我对 wpf 导航进行了更多阅读,如果您可以访问应用程序的 NavigationWindow 实例,则有一个名为 ForwardStack 的属性,它保存向前导航页面的列表。您应该能够从那里添加或删除页面。
我自己还没有尝试过这个,因为我现在没有可以测试这个的项目,所以请告诉我这是否有效,因为我想将来自己尝试一下。
有关完整成员列表,请参阅 msdn 链接: http://msdn.microsoft.com/en-我们/library/system.windows.navigation.navigationwindow_members.aspx
I read into the wpf navigation a little more and if you can get to the instance of NavigationWindow for your application there is a property called ForwardStack that holds the list of forward navigation pages. You should be able to add or remove pages from there.
I have not tried this myself as I do not have a project to test this on right now so let me know if this works as I would like to try this myself in the future.
See msdn link for full member listing: http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationwindow_members.aspx
如果您在后退后重新导航到当前页面,您应该会丢失所有前进数据,就像在 Web 浏览器或 Windows 资源管理器中一样。
如果您不希望刷新显示在返回列表中,您可以从返回列表中删除最后一个条目。
If you renavigate to the current page after you go backwards you should lose all of the forward data just like you would in a web browser or in windows explorer.
If you don't want the refresh to show in the back list you can then remove the last entry from the back list.