Пример #1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (Vm != null && _isPresentedFirstTime)
            {
                _isPresentedFirstTime = false;
                await Vm.NavigateCommand.ExecuteAsync(typeof(HomeViewModel));

                // Set the titlebar
                var textColor = ActualTheme == ElementTheme.Dark
                    ? Colors.White
                    : Colors.Black;

                // Extend UI
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

                // Set custom titlebar
                AppTitle.Foreground = new SolidColorBrush(textColor);
                Window.Current.SetTitleBar(Titlebar);

                // Update Title bar colors
                ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 20
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 60
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverForegroundColor = textColor;
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedForegroundColor = textColor;

                // Set up the "Me" View model, on mobile apps / xbox this is a seperate page, but
                // on PC, this is included in the root view.

                // Load the viewModel
                var viewModelLoader = Mvx.IoCProvider.Resolve <IMvxViewModelLoader>();
                MeVm = (MeViewModel)viewModelLoader.LoadViewModel(new MvxViewModelRequest <MeViewModel>(), null);

                Vm.GetPlaybackService().OnMediaChange += RootView_OnMediaChange;
            }
        }