Beispiel #1
0
        /// <summary>
        /// Updates the overlay UI.
        /// </summary>
        private void UpdateOverlayUI()
        {
            var chrome = WindowChrome.GetChrome(this);

            // When the overlay mode changes, ensure we clear the overlay content to ensure a switch between the Backstage modes executes the template selector again
            var viewModel = this.ViewModel;

            if (currentOverlayMode != viewModel.OverlayMode)
            {
                WindowChrome.SetOverlayContent(this, null);
                currentOverlayMode = viewModel.OverlayMode;
            }

            switch (viewModel.OverlayMode)
            {
            case ApplicationOverlayMode.ExternalSample:
                WindowChrome.SetOverlayAnimationKinds(this, OverlayAnimationKinds.Fade);
                WindowChrome.SetOverlayContent(this, "Loading external sample...");
                this.SetBinding(WindowChrome.IsOverlayVisibleProperty, new Binding()
                {
                    Source = ViewModel, Path = new PropertyPath(nameof(ApplicationViewModel.IsLoadingExternalSample)), Mode = BindingMode.TwoWay
                });
                BindingOperations.ClearBinding(this, WindowChrome.UseAlternateTitleBarStyleProperty);
                break;

            default:                      // Backstage (all kinds)
                WindowChrome.SetOverlayAnimationKinds(this, OverlayAnimationKinds.FadeSlide);
                WindowChrome.SetOverlayContent(this, viewModel);
                this.SetBinding(WindowChrome.IsOverlayVisibleProperty, new Binding()
                {
                    Source = ViewModel, Path = new PropertyPath(nameof(ApplicationViewModel.IsBackstageOpen)), Mode = BindingMode.TwoWay
                });
                this.SetBinding(WindowChrome.UseAlternateTitleBarStyleProperty, new Binding()
                {
                    Source = ViewModel, Path = new PropertyPath(nameof(ApplicationViewModel.IsBackstageOpen)), Mode = BindingMode.TwoWay
                });
                break;
            }
        }