本文整理匯總了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();
}