我已经创建了一个只有几页的框架。框架有自己的日志:
JournalOwnership="OwnsJournal"当我传递2个页面时,我想清除frame NavigationService
Frame parent_frame = (Frame)Application.Current.MainWindow.FindName("content_frame");
JournalEntry remove = parent_frame.RemoveBackEntry();
while (parent_frame.NavigationService.CanGoBack) {
parent_frame.NavigationService.RemoveBackEntry();
MessageBox.Show("Remove");
}但在清理完NavigationService之后,我可以返回。
发布于 2015-05-16 23:36:42
要做到这一点,最简单的方法是处理框架导航事件:
frame.Navigated += frame_Navigated;
void frame_Navigated(object sender, NavigationEventArgs e)
{
frame.NavigationService.RemoveBackEntry();
}发布于 2015-05-17 00:29:32
我已经删除了NavigationService.BackStack中所有可能的页面,并在删除最后一页时添加了事件。
Frame root = (Frame)Application.Current.MainWindow.FindName("content_frame");
int i = 0;
while (root.NavigationService.CanGoBack) {
i++;
root.NavigationService.RemoveBackEntry();
}
root.NavigationService.RemoveBackEntry();
MessageBox.Show("Deleted - " + i);
NavigatedEventHandler navigated_handle = null;
navigated_handle = (o, e) => {
((Frame)o).RemoveBackEntry();
MessageBox.Show("Do and remove itself!");
root.Navigated -= navigated_handle;
};
root.Navigated += navigated_handle;https://stackoverflow.com/questions/30277177
复制相似问题