我有3页。第A,B和C页。
情况如下:
在所有3个屏幕上,我使用一个对象e。 G。 Car
。那些到按钮意味着如果我点击这样一个按钮,我将通过Frame.Navigate(typeof(...), Car)
传递Car
引用导航到该页面。在后退按钮按下我想回去而不传递任何参数。
问题是当我按到C 然后到B e。 G。 5次,然后当从页面B
通过后退按钮导航时,它就像这样。 C - > B - > C - > B - > C - > B - > C - > B - >甲
我的问题是:有没有办法不向后退按钮堆栈添加导航?所以它只有一种方式C - > B - > A,或B - > A或C - > B.
我的App.xaml.cs
protected override void OnLaunched(LaunchActivatedEventArgs e) {
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
rootFrame.Navigated += OnNavigated;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
// Register a handler for BackRequested events and set the
// visibility of the Back button
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
rootFrame.CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
private void OnNavigated(object sender, NavigationEventArgs e) {
// Each time a navigation event occurs, update the Back button's visibility
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
((Frame)sender).CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
}
private void OnBackRequested(object sender, BackRequestedEventArgs e) {
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame.CanGoBack) {
e.Handled = true;
rootFrame.GoBack();
}
}
提前谢谢。
答案 0 :(得分:0)
基本上你不想在<script type="text/javascript">
$(document).ready(function(){
countnumber(0,40,"stat1",50);
function countnumber(start,end,idtarget,duration){
cc=setInterval(function(){
if(start==end)
{
$("#"+idtarget).html(start);
clearInterval(cc);
}
else
{
$("#"+idtarget).html(start);
start++;
}
},duration);
}
});
</script>
<span id="span1"></span>
中重复。这是导航发生时你可以做的事情。
BackStack
答案 1 :(得分:0)
实际上,your answer给了我如何解决它的想法。我刚刚修改了一些代码。
if (this.Frame.BackStackDepth > 1) {
var firstItem = this.Frame.BackStack.Distinct().ToList().First();
this.Frame.BackStack.Clear();
this.Frame.BackStack.Add(firstItem);
}
我只检索后面堆栈中的第一个不同项,然后我只将这一项设置为堆栈跟踪。