public NavigationRootPage() { this.InitializeComponent(); _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl); SetDeviceFamily(); AddNavigationMenuItems(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad if (FocusManager.GetFocusedElement() is FrameworkElement focus) { Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); } }; Gamepad.GamepadAdded += OnGamepadAdded; Gamepad.GamepadRemoved += OnGamepadRemoved; Window.Current.SetTitleBar(AppTitleBar); CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s); _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent); }
private Frame GetRootFrame() { Frame rootFrame; NavigationRootPage rootPage = Window.Current.Content as NavigationRootPage; if (rootPage == null) { rootPage = new NavigationRootPage(); rootFrame = (Frame)rootPage.FindName("rootFrame"); if (rootFrame == null) { throw new Exception("Root frame not found"); } SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootPage; } else { rootFrame = (Frame)rootPage.FindName("rootFrame"); } return(rootFrame); }
async void NavigationRootPage_Loaded(object sender, RoutedEventArgs e) { this.DataContext = await ControlInfoDataSource.GetGroupsAsync(); Current = this; RootFrame = rootFrame; }
public NavigationRootPage() { this.InitializeComponent(); this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame); LoadGroups(); Current = this; RootFrame = rootFrame; }
private async Task ShowWindow(LaunchActivatedEventArgs e) { NavigationRootPage rootPage = Window.Current.Content as NavigationRootPage; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootPage == null) { rootPage = new NavigationRootPage(); // Retrieve the root Frame to act as the navigation context and navigate to the first page Frame rootFrame = (Frame)rootPage.FindName("rootFrame"); if (rootFrame == null) { throw new Exception("Root frame not found"); } // Associate the frame with a SuspensionManager key. SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page. rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Place the main page in the current Window. Window.Current.Content = rootPage; } // Ensure the current window is active Window.Current.Activate(); }
public NavigationRootPage() { this.InitializeComponent(); this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame); LoadGroups(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad FrameworkElement focus = FocusManager.GetFocusedElement() as FrameworkElement; if (focus != null) Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); }; }
public NavigationRootPage() { this.InitializeComponent(); // Workaround for VisualState issue that should be fixed // by https://github.com/microsoft/microsoft-ui-xaml/pull/2271 NavigationViewControl.PaneDisplayMode = muxc.NavigationViewPaneDisplayMode.Left; _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl); SetDeviceFamily(); AddNavigationMenuItems(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad if (FocusManager.GetFocusedElement() is FrameworkElement focus) { Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); } }; Gamepad.GamepadAdded += OnGamepadAdded; Gamepad.GamepadRemoved += OnGamepadRemoved; Window.Current.SetTitleBar(AppTitleBar); CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s); _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent); // remove the solid-colored backgrounds behind the caption controls and system back button // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet Loaded += delegate(object sender, RoutedEventArgs e) { ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; }; NavigationViewControl.RegisterPropertyChangedCallback(muxc.NavigationView.PaneDisplayModeProperty, new DependencyPropertyChangedCallback(OnPaneDisplayModeChanged)); }
public NavigationRootPage() { this.InitializeComponent(); this.rootFrameNavigationHelper = new RootFrameNavigationHelper(rootFrame); LoadGroups(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad FrameworkElement focus = FocusManager.GetFocusedElement() as FrameworkElement; if (focus != null) { Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); } }; }
public NavigationRootPage() { this.InitializeComponent(); _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl); SetDeviceFamily(); AddNavigationMenuItems(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad if (FocusManager.GetFocusedElement() is FrameworkElement focus) { Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); } }; this.Loaded += (s, e) => { // This is to work around a bug in the NavigationView header that hard-codes the header content to a 48 pixel height. var headerContentControl = NavigationViewControl.GetDescendantsOfType <ContentControl>().Where(c => c.Name == "HeaderContent").FirstOrDefault(); if (headerContentControl != null) { headerContentControl.Height = double.NaN; } }; Gamepad.GamepadAdded += OnGamepadAdded; Gamepad.GamepadRemoved += OnGamepadRemoved; Window.Current.CoreWindow.SizeChanged += (s, e) => UpdateAppTitle(); CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(); _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent); }
public NavigationRootPage() { this.InitializeComponent(); LoadGroups(); Current = this; RootFrame = rootFrame; //Loaded += NavigationRootPage_Loaded; //Use the hardware back button instead of showing the back button in the page if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, e) => { if (rootFrame.CanGoBack) { rootFrame.GoBack(); e.Handled = true; } }; } }
public NavigationRootPage() { this.InitializeComponent(); _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl); SetDeviceFamily(); AddNavigationMenuItems(); Current = this; RootFrame = rootFrame; this.GotFocus += (object sender, RoutedEventArgs e) => { // helpful for debugging focus problems w/ keyboard & gamepad if (FocusManager.GetFocusedElement() is FrameworkElement focus) { Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")"); } }; Gamepad.GamepadAdded += OnGamepadAdded; Gamepad.GamepadRemoved += OnGamepadRemoved; //Window.Current.SetTitleBar(AppTitleBar); CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s); _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent); // remove the solid-colored backgrounds behind the caption controls and system back button // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet Loaded += delegate(object sender, RoutedEventArgs e) { ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; var currentTheme = App.RootTheme.ToString(); bool darkTheme = false; switch (currentTheme) { case "Dark": darkTheme = true; break; case "Default": if (Application.Current.RequestedTheme == ApplicationTheme.Dark) { darkTheme = true; } break; } if (darkTheme) { titleBar.ButtonForegroundColor = Colors.White; } else { titleBar.ButtonForegroundColor = Colors.Black; } }; }