public static void SetTitle(string title) { SplitViewShell shell = Window.Current.Content as SplitViewShell; if (shell != null) { shell.SetTitle(title); shell.SetSelectedPage(title); } }
protected async override void OnLaunched(LaunchActivatedEventArgs e) { var shell = Window.Current.Content as SplitViewShell; if (shell == null) { Frame rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Xamarin.Forms.Forms.Init(e); //Register platform specific implementations of shared interfaces //2 ServiceLocator.Instance.Add<IAuthentication, Authentication>(); //3 ServiceLocator.Instance.Add<Utils.Interfaces.ILogger, PlatformLogger>(); ServiceLocator.Instance.Add <IOBDDevice, OBDDevice>(); Xamarin.Forms.DependencyService.Register <ObdLibUWP.ObdWrapper>(); //4 if (Settings.Current.IsLoggedIn) { //When the first screen of the app is launched after user has logged in, initialize the processor that manages connection to OBD Device and to the IOT Hub await MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize(ViewModel.ViewModelBase.StoreManager); //await MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize(); // Create the shell and set it to current trip shell = new SplitViewShell(rootFrame); shell.SetTitle("CURRENT TRIP"); shell.SetSelectedPage("CURRENT TRIP"); rootFrame.Navigate(typeof(CurrentTripView), e.Arguments); Window.Current.Content = shell; } /*6 else if (Settings.Current.FirstRun) * { * rootFrame.Navigate(typeof(GetStarted1), e.Arguments); * Window.Current.Content = rootFrame; * } * else * { * rootFrame.Navigate(typeof(LoginView), e.Arguments); * Window.Current.Content = rootFrame; * } */ } Window.Current.Activate(); }
/// <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) { SplitViewShell shell = Window.Current.Content as SplitViewShell; // Do not repeat app initialization when the Window is already present, // just ensure that the window is active if (shell == null) { // Create a Frame to act as the navigation context and navigate to the first page Frame rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; //Register platform specific implementations of shared interfaces ServiceLocator.Instance.Add <IAuthentication, Authentication>(); ServiceLocator.Instance.Add <Utils.Interfaces.ILogger, PlatformLogger>(); ServiceLocator.Instance.Add <IOBDDevice, OBDDevice>(); if (Settings.Current.IsLoggedIn) { //When the first screen of the app is launched after user has logged in, initialize the processor that manages connection to OBD Device and to the IOT Hub MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize(ViewModel.ViewModelBase.StoreManager); // Create the shell and set it to current trip shell = new SplitViewShell(rootFrame); shell.SetTitle("CURRENT TRIP"); shell.SetSelectedPage("CURRENT TRIP"); rootFrame.Navigate(typeof(CurrentTripView), e.Arguments); Window.Current.Content = shell; } else if (Settings.Current.FirstRun) { rootFrame.Navigate(typeof(GetStarted1), e.Arguments); Window.Current.Content = rootFrame; } else { rootFrame.Navigate(typeof(LoginView), e.Arguments); Window.Current.Content = rootFrame; } } // Ensure the current window is active Window.Current.Activate(); }