public AppShell(string path) { // Init the XAML LoggingService.Log(LoggingService.LogType.Debug, "Loading Shell XAML"); InitializeComponent(); // Set the accent color TitlebarHelper.UpdateTitlebarStyle(); LoggingService.Log(LoggingService.LogType.Debug, "Attaching Event Handlers"); // When the page is loaded (after the following and xaml init) // we can perform the async work Loaded += async(sender, args) => await PerformAsyncWork(path); // Unload events Unloaded += (sender, args) => Dispose(); var titleBar = CoreApplication.GetCurrentView().TitleBar; titleBar.LayoutMetricsChanged += (s, e) => { AppTitle.Margin = new Thickness(CoreApplication.GetCurrentView().TitleBar.SystemOverlayLeftInset + 12, 8, 0, 0); }; // This is a dirty to show the now playing // bar when a track is played. This method // updates the required layout for the now // playing bar. PlaybackService.Instance.OnTrackChange += InstanceOnOnCurrentTrackChanged; // Create a shell frame shadow for mobile and desktop if (DeviceHelper.IsDesktop) { ShellFrame.CreateElementShadow(new Vector3(4, 0, 0), 40, new Color { A = 82, R = 0, G = 0, B = 0 }, ShellFrameShadow); } // Events for Xbox if (DeviceHelper.IsXbox) { // Make xbox selection easy to see Application.Current.Resources["CircleButtonStyle"] = Application.Current.Resources["XboxCircleButtonStyle"]; } RootFrame.Focus(FocusState.Keyboard); }
public MainShell(string path) { // Init the XAML InitializeComponent(); // Set the accent color TitlebarHelper.UpdateTitlebarStyle(); // When the page is loaded (after the following and xaml init) // we can perform the async work Loaded += async(sender, args) => await PerformAsyncWork(path); // Unload events Unloaded += (sender, args) => Dispose(); // This is a dirty to show the now playing // bar when a track is played. This method // updates the required layout for the now // playing bar. PlaybackService.Instance.PropertyChanged += ServiceOnPropertyChanged; // Create a shell frame shadow for mobile and desktop if (DeviceHelper.IsDesktop || DeviceHelper.IsMobile) { ShellFrame.CreateElementShadow(new Vector3(0, 0, 0), 20, new Color { A = 52, R = 0, G = 0, B = 0 }, ShellFrameShadow); } // Events for Xbox if (DeviceHelper.IsXbox) { // Pane is hidden by default MainSplitView.IsPaneOpen = false; MainSplitView.DisplayMode = SplitViewDisplayMode.CompactOverlay; MainSplitView.Margin = new Thickness(); MainSplitView.LightDismissOverlayMode = LightDismissOverlayMode.On; // Center all navigation icons NavbarScrollViewer.VerticalAlignment = VerticalAlignment.Center; // Show background blur image XboxOnlyGrid.Visibility = Visibility.Visible; ShellFrame.Background = new SolidColorBrush(Colors.Transparent); // Splitview pane gets background SplitViewPaneGrid.Background = Application.Current.Resources["InAppBackgroundBrush"] as CustomAcrylicBrush; // Make xbox selection easy to see Application.Current.Resources["CircleButtonStyle"] = Application.Current.Resources["XboxCircleButtonStyle"]; } // Events for Mobile if (DeviceHelper.IsMobile) { // Splitview pane gets background SplitViewPaneGrid.Background = Application.Current.Resources["MobileBlurHeader"] as CustomAcrylicBrush; // Amoled Magic Application.Current.Resources["ShellBackground"] = new SolidColorBrush(Application.Current.RequestedTheme == ApplicationTheme.Dark ? Colors.Black : Colors.White); MainSplitView.IsPaneOpen = false; MainSplitView.DisplayMode = SplitViewDisplayMode.Overlay; MainSplitView.Margin = new Thickness(0); SplitViewPaneGrid.Margin = new Thickness { Top = 48 }; MobileMenu.Visibility = Visibility.Visible; HamburgerButton.Visibility = Visibility.Collapsed; } if (DeviceHelper.IsDesktop) { MainSplitView.IsPaneOpen = SettingsService.Instance.IsMenuOpen; } // Focus on the root frame RootFrame.Focus(FocusState.Programmatic); }