public static bool NavigateToLocation(this Windows.UI.Xaml.Controls.Frame frame, string location) { try { return(frame.Navigate(PageMap[location])); } catch (KeyNotFoundException) { return(frame.Navigate(typeof(NotAvailablePage))); } }
private void GoBackFunc() { Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; frame.BackStack.Clear(); if (prototype != null && prototype.Name != null) { frame.Navigate(typeof(DetailsPrototypePage), prototype.PrototypeId); } else { frame.Navigate(typeof(PrototypesPage)); } }
protected override void OnLaunched(LaunchActivatedEventArgs e) { // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (!(Window.Current.Content is Windows.UI.Xaml.Controls.Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Windows.UI.Xaml.Controls.Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Forms.SetFlags("Shell_UWP_Experimental", "AppTheme_Experimental"); Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
private async void CancelFunc() { if (!_ringContentVisibility) { using (var db = new PrototypingContext()) { User user = db.Users.Single(u => u.UserId == userId); Record record = db.Records.Last(); db.Entry(user).Reference(u => u.Prototype).Load(); try { StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(user.Prototype.Name + "_" + user.PrototypeId); StorageFolder userFolder = await prototypeFolder.GetFolderAsync(user.Name + "_" + user.UserId); StorageFolder recordFolder = await userFolder.GetFolderAsync("Record_" + recordSettings.RecordId); await recordFolder.DeleteAsync(); } catch (System.IO.FileNotFoundException) { } db.Records.Remove(record); db.SaveChanges(); } Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; frame.BackStack.Clear(); frame.Navigate(typeof(DetailsUserPage), userId); } }
/// <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) { // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // 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(); }
/// <summary> /// 네비게이션 /// </summary> /// <param name="navigation"></param> /// <param name="navigationParameter"></param> /// <returns></returns> public override bool Navigation(string navigation, object navigationParameter) { var returnValue = false; if (_frame == null) { return(false); } if (navigation == "GoBack") { if (_frame.CanGoBack) { _frame.GoBack(); } return(true); } var t = Windows.UI.Xaml.Application.Current.GetType().GetTypeInfo().Assembly.GetType(navigation); if (t != null && t != typeof(Uri)) { returnValue = _frame.Navigate(t, navigationParameter); } return(returnValue); }
/// <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) { // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; var assembliesToInclude = new List <Assembly> { typeof(CachedImage).GetTypeInfo().Assembly, typeof(CachedImageRenderer).GetTypeInfo().Assembly, typeof(ContactManager).GetTypeInfo().Assembly }; Forms.Init(e, assembliesToInclude); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
internal static bool Navigate(this Windows.UI.Xaml.Controls.Frame frame, ContentPage page, Windows.UI.Xaml.Media.Animation.NavigationTransitionInfo infoOverride) { if (page == null) { throw new ArgumentNullException(nameof(page)); } Guid id = Guid.NewGuid(); FormsEmbeddedPageWrapper.Pages.Add(id, page); if (infoOverride != null) { return(frame.Navigate(typeof(FormsEmbeddedPageWrapper), id, infoOverride)); } return(frame.Navigate(typeof(FormsEmbeddedPageWrapper), id)); }
private void GoBackFunc() { Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; frame.BackStack.Clear(); if (_prototypeId >= 0) { frame.Navigate(typeof(DetailsPrototypePage), _prototypeId); } if (_userId >= 0) { frame.Navigate(typeof(DetailsUserPage), _userId); } if (_recordId >= 0) { frame.Navigate(typeof(EmotionsPage), _recordId); } }
private void GoToLookEmotions() { Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; using (var db = new PrototypingContext()) { if (prototypeId >= 0) { frame.Navigate(typeof(SummaryEmotionsPage), db.Prototypes.Single(p => p.PrototypeId == prototypeId)); } if (userId >= 0) { frame.Navigate(typeof(SummaryEmotionsPage), db.Users.Single(u => u.UserId == userId)); } if (RecordModel != null) { frame.Navigate(typeof(EmotionsPage), RecordModel.RecordId); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); OAuthProviderSetting oauth = new OAuthProviderSetting(); var auth = oauth.LoginWithProvider("Facebook"); Windows.UI.Xaml.Controls.Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Windows.UI.Xaml.Controls.Frame; rootFrame.Navigate(auth.GetUI(), auth); }
private void GoBackFunc() { if (!_ringContentVisibility) { Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; frame.BackStack.Clear(); if (prototypeId >= 0) { frame.Navigate(typeof(DetailsPrototypePage), prototypeId); } if (userId >= 0) { frame.Navigate(typeof(DetailsUserPage), userId); } if (RecordModel != null) { frame.Navigate(typeof(DetailsUserPage), RecordModel.UserId); } } }
public void goToPage(Type page) { Windows.UI.Xaml.Window window = Windows.UI.Xaml.Window.Current; if (window != null) { Windows.UI.Xaml.Controls.Frame frame = window.Content as Windows.UI.Xaml.Controls.Frame; if (frame != null) { frame.Navigate(page); } } }
public static void Navigate(Type typeOfPage) { Windows.UI.Xaml.Window window = Windows.UI.Xaml.Window.Current; if (window != null) { Windows.UI.Xaml.Controls.Frame frame = window.Content as Windows.UI.Xaml.Controls.Frame; if (frame != null) { frame.Navigate(typeOfPage); } } }
public static bool Navigate(this Windows.UI.Xaml.Controls.Frame frame, ContentPage page) { if (page == null) { throw new ArgumentNullException(nameof(page)); } Guid id = Guid.NewGuid(); FormsEmbeddedPageWrapper.Pages.Add(id, page); return(frame.Navigate(typeof(FormsEmbeddedPageWrapper), id)); }
public void Login(Authenticator authenticator) { authenticator.Completed += AuthenticatorCompleted; System.Type page_type = authenticator.GetUI(); Windows.UI.Xaml.Controls.Frame root_frame = null; root_frame = Windows.UI.Xaml.Window.Current.Content as Windows.UI.Xaml.Controls.Frame; root_frame.Navigate(page_type, authenticator); return; }
public void TabView_AddTabButtonClick(TabView sender, object args) { var frame = new Windows.UI.Xaml.Controls.Frame(); frame.Navigate(typeof(TestPage)); var tab = new TabViewItem { Header = "Broken", Content = frame }; Tabs.Add(tab); }
public FramePageViewModel() { MainFrame = new Windows.UI.Xaml.Controls.Frame(); string navigationState = MainFrame.GetNavigationState(); MainFrame.Navigated += (sender, args) => { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = MainFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }; MainFrame.Navigate(typeof(HomePage)); SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; NavigateCommand = new DelegateCommand(NavigateCommandImpl, NavigateCommandCanExecute); }
public async Task OpenSecondaryWindow(ContentPage page) { CoreApplicationView newView = CoreApplication.CreateNewView(); int newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var frame = new Windows.UI.Xaml.Controls.Frame(); frame.Navigate(page); Window.Current.Content = frame; Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; }); bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); }
/// <summary> /// </summary> /// <param name="e"></param> protected override void OnLaunched(LaunchActivatedEventArgs e) { if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Forms.Init(e); Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Activate(); }
public async Task NewWindow() { CoreApplicationView newView = CoreApplication.CreateNewView(); int newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Windows.UI.Xaml.Controls.Frame frame = new Windows.UI.Xaml.Controls.Frame(); frame.Navigate(typeof(MainPage)); Window.Current.Content = frame; // You have to activate the window in order to show it later. Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; }); bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); }
private bool NavigateCore <T_VM> (T_VM parameter) where T_VM : ViewModel.Base { bool result; CurrentViewModel = parameter; var viewModelType = typeof(T_VM); var viewType = m_vm.GetView <T_VM> ( ); if (viewType == null) { throw new NavigationException("Unable to find view for type '" + viewModelType.FullName + "'."); } result = m_frame.Navigate(viewType, parameter); return(result); }
/// <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(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs e) { // Resize app. uint screenWidthInRawPixels = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().ScreenWidthInRawPixels; uint screenHeightInRawPixels = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().ScreenHeightInRawPixels; double rawPixelsPerViewPixel = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; double screenWidthInViewPixels = System.Convert.ToDouble(screenWidthInRawPixels) / rawPixelsPerViewPixel; double screenHeightInViewPixels = System.Convert.ToDouble(screenHeightInRawPixels) / rawPixelsPerViewPixel; // If offsetToScreenWidthInViewPixels is less than 15, // on first load app will be of default size, and on second load app will be full screen. // A loaded image will have height equal to full screen height minus app title bar height minus app toolbar height minus 5 view pixels of padding. // Part of a loaded image with aspect ratio less than one will be behind Windows taskbar. // This is all very complicated and undesirable. // If offsetToScreenHeightInViewPixels is less than 40, // on first load app will be of default size, and on second load app will be full screen. // A loaded image will have height equal to full screen height minus app title bar height minus app toolbar height minus 5 view pixels of padding. // Part of a loaded image with aspect ratio less than one will be behind Windows taskbar. // This is all very complicated and undesirable. // If offsetToScreenWidthInViewPixels is greater than or equal to 15 and offsetToScreenHeightInViewPixels is greater than or equal to 40, // on first load app will be of PreferredLaunchViewSize, and a loaded image with aspect ratio less than one will have height exactly equal to height of app minus app title bar height minus app toolbar height. // If PreferredLaunchViewSize.Height is only screenHeightInViewPixels - offsetToScreenHeightInViewPixels, // part of app and a loaded image with aspect ratio less than one will be behind taskbar. // If taskbarHeight is taken off of screenHeightInViewPixels - offsetToScreenHeightInViewPixels, // bottom of app and coincident bottom of loaded image will be slightly above taskbar. // I consider this ideal. double offsetToScreenWidthInViewPixels = 15; double offsetToScreenHeightInViewPixels = 40; double taskbarHeight = 40; Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize = new Windows.Foundation.Size(screenWidthInViewPixels - offsetToScreenWidthInViewPixels, screenHeightInViewPixels - offsetToScreenHeightInViewPixels - taskbarHeight); Windows.UI.ViewManagement.ApplicationView.PreferredLaunchWindowingMode = Windows.UI.ViewManagement.ApplicationViewWindowingMode.PreferredLaunchViewSize; // Set the app window to a new Frame. Windows.UI.Xaml.Controls.Frame rootFrame = new Windows.UI.Xaml.Controls.Frame(); Windows.UI.Xaml.Window.Current.Content = rootFrame; // Navigate the frame to the initial default page. rootFrame.Navigate(typeof(MainPage), e.Arguments); // Attempts to activate the application window by bringing it to the foreground and setting the input focus to it. Windows.UI.Xaml.Window.Current.Activate(); } // protected override void OnLaunched
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); if (showLogin && FacebookAuth.User == null) { showLogin = false; var loginPage = Element as ProviderLoginPage; string providername = loginPage.ProviderName; WindowsPage windowsPage = new WindowsPage(); var auth = GetAuthenticator(providername); _frame = windowsPage.Frame; if (_frame == null) { _frame = new Windows.UI.Xaml.Controls.Frame(); //_frame.Language = global::Windows.Globalization.ApplicationLanguages.Languages[0]; windowsPage.Content = _frame; SetNativeControl(windowsPage); } auth.Completed += async(sender, eventArgs) => { if (eventArgs.IsAuthenticated) { var request = GetRequest(providername); request.Account = eventArgs.Account; var fbResponse = await request.GetResponseAsync(); FacebookAuth.SetUser(providername, fbResponse.GetResponseText()); } else { // The user cancelled } }; _frame.Navigate(auth.GetUI(), auth); Window.Current.Activate(); } }
private void loginButtonAction() { var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("login", UserLogin), new KeyValuePair <string, string>("password", UserPassword) }); if (WebRequest.Instance.GetAccessToken(content, UserLogin) == true) { Windows.UI.Xaml.Window window = Windows.UI.Xaml.Window.Current; if (window != null) { Windows.UI.Xaml.Controls.Frame frame = window.Content as Windows.UI.Xaml.Controls.Frame; if (frame != null) { frame.Navigate(typeof(UserPage)); } } } }
public LoginFacebookRenderer() { //Usando o OAuth(Xamarin.Auth) var oauth = new OAuth2Authenticator( clientId: "1278399355605621", scope: "email", authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html") ); oauth.Completed += async(sender, args) => { if (args.IsAuthenticated) { //Acesso aos dados - Token de Acesso var token = args.Account.Properties["access_token"].ToString(); var requisicao = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=name,email"), null, args.Account); var resposta = await requisicao.GetResponseAsync(); var obj = Newtonsoft.Json.Linq.JObject.Parse(resposta.GetResponseText()); var Nome = obj["name"].ToString().Replace("\"", ""); var Email = obj["email"].ToString().Replace("\"", ""); App18.App.NavegarParaInicial(Nome, Email); } else { App18.App.NavegarParaInicial("Login rejeitado"); } }; Windows.UI.Xaml.Controls.Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Windows.UI.Xaml.Controls.Frame; rootFrame.Navigate(oauth.GetUI(), oauth); }
/// <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) { // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (!(Window.Current.Content is Frame root)) { // Initialize Blazor Task.Run((Action)Bootstrapper.Bootstrap).ContinueWith(async _ => { // TODO: Properly detect when things are ready. await Task.Delay(1000); Startup.Main(); }); // Initialize Xamain.Forms Forms.Init(e); // Create a Frame to act as the navigation context and navigate to the first page root = new Frame(); root.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = root; } if (root.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 root.Navigate(typeof(MainPage), e.Arguments); } //Ensure the current window is active Window.Current.Activate(); }
async void _navigationForward() { var vm = _xNavigation.CurrentContentObject; var currentPage = _rootElement.Content as XPage; if (currentPage != null && currentPage.DataContext != null && currentPage.DataContext == vm) { //This page is already correct (probably an out of XCore back) return; } var p = _viewResolver.ResolvePageType(vm); if (p == null) { throw new Exception("View type not implemented"); } _rootElement.Navigate(p, _xNavigation.CurrentContentObject); if (currentPage != null && !_xNavigation.NavigationHistory.Contains(currentPage.DataContext) && _rootElement.BackStack.Any(_ => _.Parameter == currentPage.DataContext) ) { var itemsToRemove = _rootElement.BackStack.Where(_ => _.Parameter == currentPage.DataContext); foreach (var item in itemsToRemove) { _rootElement.BackStack.Remove(item); } } _updateSystemButton(); }
/// <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) { // Do not repeat app initialization when the Window already has content, just ensure // that the window is active if (!(Window.Current.Content is Windows.UI.Xaml.Controls.Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Windows.UI.Xaml.Controls.Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // FFImageLoading /////////////////////////////////////////////////////////////////////////////////////////// FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); var config = new FFImageLoading.Config.Configuration() { VerboseLogging = false, VerbosePerformanceLogging = false, VerboseMemoryCacheLogging = false, VerboseLoadingCancelledLogging = false, }; FFImageLoading.ImageService.Instance.Initialize(config); var assembliesToInclude = new List <Assembly> { typeof(CachedImage).GetTypeInfo().Assembly, typeof(FFImageLoading.Forms.Platform.CachedImageRenderer).GetTypeInfo().Assembly, typeof(GrampsView.App).GetTypeInfo().Assembly }; // App Center ////////////////////////////////////////////////////////////////////////////////////////////////Debug.WriteLine(initString, "AppCenterInit"); Debug.WriteLine(AppCenter.SdkVersion, "UWP SDK"); // Forms Init //////////////////////////////////////////////////////////////////////////////////////////////// global::Xamarin.Forms.Forms.SetFlags("Shell_UWP_Experimental"); Xamarin.Forms.Forms.Init(e, assembliesToInclude); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application // Need to remember current location first but is this worth the effort? } // 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(); }
private void GoBackFunc() { Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content; frame.BackStack.Clear(); frame.Navigate(typeof(DetailsUserPage), userId); }