本文整理汇总了C#中Windows.UI.Xaml.Controls.Frame.GoBack方法的典型用法代码示例。如果您正苦于以下问题:C# Frame.GoBack方法的具体用法?C# Frame.GoBack怎么用?C# Frame.GoBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.Frame
的用法示例。
在下文中一共展示了Frame.GoBack方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GoBack
public static void GoBack(Frame Frame)
{
if (Frame.CanGoBack)
{
Frame.GoBack();
}
}
示例2: Register
public static void Register(Frame frame, NavigationHelperConfig config)
{
Action backAction = () =>
{
if (frame.CanGoBack)
{
frame.GoBack();
}
};
Register(frame, backAction);
}
示例3: OnBackPressed
/// <summary>
/// Handles back button press. If app is at the root page of app, don't go back and the
/// system will suspend the app.
/// </summary>
/// <param name="sender">The source of the BackPressed event.</param>
/// <param name="e">Details for the BackPressed event.</param>
private void OnBackPressed(object sender, BackPressedEventArgs e)
{
RootFrame = Window.Current.Content as Frame;
if (RootFrame == null)
{
return;
}
if (RootFrame.CanGoBack)
{
RootFrame.GoBack();
e.Handled = true;
}
}
示例4: HardwareButtons_BackPressed
/// <summary>
/// Handles back button press. If app is at the root page of app, don't go back and the
/// system will suspend the app.
/// </summary>
/// <param name="sender">The source of the BackPressed event.</param>
/// <param name="e">Details for the BackPressed event.</param>
private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
ApplicationFrame = Window.Current.Content as Frame;
if (ApplicationFrame == null)
{
return;
}
if (ApplicationFrame.CanGoBack)
{
ApplicationFrame.GoBack();
e.Handled = true;
}
}
示例5: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
// this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
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)
{
var a= DeviceInfo.DeviceScreenSize;
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.Navigated += RootFrame_Navigated;
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
Window.Current.SizeChanged += Current_SizeChanged;
// Place the frame in the current Window
Window.Current.Content = rootFrame;
SystemNavigationManager.GetForCurrentView().BackRequested += (s, ea) =>
{
while (rootFrame.CanGoBack)
{ rootFrame.GoBack(); ea.Handled = true; }
};
}
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();
}
示例6: PageWithBackAndForward
public Page PageWithBackAndForward( ) {
var frame = new Frame( );
Page page = null;
frame.Navigated += (object sender, NavigationEventArgs e) => {
page = e.Content as Page;
};
frame.Navigate(typeof(Page));
frame.Navigate(typeof(Page));
frame.Navigate(typeof(Page));
frame.GoBack( );
return page;
}
示例7: OnLaunched
/// <summary>
/// 在应用程序由最终用户正常启动时进行调用。
/// 将在启动应用程序以打开特定文件等情况下使用。
/// </summary>
/// <param name="e">有关启动请求和过程的详细信息。</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
//#if DEBUG
// if (System.Diagnostics.Debugger.IsAttached)
// {
// this.DebugSettings.EnableFrameRateCounter = true;
// }
//#endif
//http://blogs.u2u.be/diederik/post/2015/07/28/A-lap-around-Adaptive-Triggers.aspx
// Override default minimum size.
var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
view.SetPreferredMinSize(new Size { Width = 320, Height = 480 });
Frame rootFrame = Window.Current.Content as Frame;
// 不要在窗口已包含内容时重复应用程序初始化,
// 只需确保窗口处于活动状态
if (rootFrame == null)
{
// 创建要充当导航上下文的框架,并导航到第一页
rootFrame = new Frame();
//【Win10】页面导航的实现
//http://www.cnblogs.com/h82258652/p/4996087.html
rootFrame.Navigated += delegate
{
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility
= rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
};
SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) =>
{
if (rootFrame.CanGoBack)
{
args.Handled = true;
rootFrame.GoBack();
}
};
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated || e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{
//TODO: 从之前挂起的应用程序加载状态
UserData.Load();
}
// 将框架放在当前窗口中
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// 当导航堆栈尚未还原时,导航到第一页,
// 并通过将所需信息作为导航参数传入来配置
// 参数
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s1, e1) =>
{
if (rootFrame != null)
{
if (rootFrame.CanGoBack)
{
e1.Handled = true;
rootFrame.GoBack();
}
}
};
}
// 确保当前窗口处于活动状态
Window.Current.Activate();
}
示例8: ResiterBackMethod
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
private void ResiterBackMethod(Frame rootFrame)
{
SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
{
if (rootFrame.CanGoBack)
{
rootFrame.GoBack();
a.Handled = true;
}
};
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
rootFrame.CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
}
示例9: OnLaunched
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
//#if DEBUG
// if (System.Diagnostics.Debugger.IsAttached)
// {
// this.DebugSettings.EnableFrameRateCounter = true;
// }
//#endif
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;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, a) =>
{
if (rootFrame.CanGoBack)
{
rootFrame.GoBack();
a.Handled = true;
}
};
/*if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
{
Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
{
Debug.WriteLine("BackPressed");
if (Frame.CanGoBack)
{
Frame.GoBack();
a.Handled = true;
}
};
}*/
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
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();
try
{
await BluetoothClient.Instance.Connect();
//new MessageDialog("Connected").ShowAsync();
Logger.Info("BT Connected");
try
{
var toastTemplate = ToastTemplateType.ToastText02;
var toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
toastXml.GetElementsByTagName("text")[0].AppendChild(toastXml.CreateTextNode("BT Connected"));
var toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
}
catch { }
}
catch (Exception ex)
{
//new MessageDialog("Not Connected").ShowAsync();
Logger.Error(ex, "BT Not Connected");
}
}
示例10: goBack
private void goBack(Frame frame)
{
if (!frame.CanGoBack)
return;
frame.GoBack();
}