コード例 #1
0
        /// <summary>
        /// Initializes the WindowChromeBehavior which is needed to render the custom WindowChrome.
        /// </summary>
        private void InitializeWindowChromeBehavior()
        {
            var behavior = new WindowChromeBehavior();

            BindingOperations.SetBinding(behavior, WindowChromeBehavior.ResizeBorderThicknessProperty, new Binding {
                Path = new PropertyPath(ResizeBorderThicknessProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.IgnoreTaskbarOnMaximizeProperty, new Binding {
                Path = new PropertyPath(IgnoreTaskbarOnMaximizeProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.KeepBorderOnMaximizeProperty, new Binding {
                Path = new PropertyPath(KeepBorderOnMaximizeProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.TryToBeFlickerFreeProperty, new Binding {
                Path = new PropertyPath(TryToBeFlickerFreeProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.EnableMinimizeProperty, new Binding {
                Path = new PropertyPath(ShowMinButtonProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.EnableMaxRestoreProperty, new Binding {
                Path = new PropertyPath(ShowMaxRestoreButtonProperty), Source = this
            });

            this.SetBinding(IsNCActiveProperty, new Binding {
                Path = new PropertyPath(WindowChromeBehavior.IsNCActiveProperty), Source = behavior
            });

            Interaction.GetBehaviors(this).Add(behavior);
        }
コード例 #2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

//			PART_Border         = (Border)Template.FindName("PART_Border"        , this);
//			PART_Panel          = (Panel )Template.FindName("PART_Panel"         , this);
            PART_TitleBar       = (Panel )Template.FindName("PART_TitleBar", this);
            PART_Minimize       = (Button)Template.FindName("PART_Minimize", this);
            PART_Restore        = (Button)Template.FindName("PART_Restore", this);
            PART_Maximize       = (Button)Template.FindName("PART_Maximize", this);
            PART_Fullscreen     = (Button)Template.FindName("PART_Fullscreen", this);
            PART_Close          = (Button)Template.FindName("PART_Close", this);
            PART_ExitFullscreen = (Button)Template.FindName("PART_ExitFullscreen", this);

            _window = Window;
            if (!DesignerProperties.GetIsInDesignMode(this) && _window != null)
            {
                _WindowChromeBehavior = new WindowChromeBehavior {
                    ResizeBorderWidth = 3,
                    TitleBar          = PART_TitleBar,
//					Border               = PART_Border,
                    CloseButton          = PART_Close,
                    MaximizeButton       = PART_Maximize,
                    MinimizeButton       = PART_Minimize,
                    RestoreButton        = PART_Restore,
                    FullScreenButton     = PART_Fullscreen,
                    ExitFullScreenButton = PART_ExitFullscreen,
                    NoCollapseTitleBar   = false,
                    VirtualCaptionHeight = 50
                };
                Interaction.GetBehaviors(Window).Add(_WindowChromeBehavior);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes the WindowChromeBehavior which is needed to render the custom WindowChrome.
        /// </summary>
        private void InitializeWindowChromeBehavior()
        {
            var behavior = new WindowChromeBehavior();

            BindingOperations.SetBinding(behavior, WindowChromeBehavior.ResizeBorderThicknessProperty, new Binding {
                Path = new PropertyPath(ResizeBorderThicknessProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.IgnoreTaskbarOnMaximizeProperty, new Binding {
                Path = new PropertyPath(IgnoreTaskbarOnMaximizeProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, GlowWindowBehavior.GlowBrushProperty, new Binding {
                Path = new PropertyPath(GlowBrushProperty), Source = this
            });

            Interaction.GetBehaviors(this).Add(behavior);
        }
コード例 #4
0
        /// <summary>
        /// Initializes the WindowChromeBehavior which is needed to render the custom WindowChrome
        /// </summary>
        private void InitializeWindowChromeBehavior()
        {
            var behavior = new WindowChromeBehavior();

            BindingOperations.SetBinding(behavior, WindowChromeBehavior.CaptionHeightProperty, new Binding {
                Path = new PropertyPath(TitleBarHeightProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.ResizeBorderThicknessProperty, new Binding {
                Path = new PropertyPath(ResizeBorderThicknessProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.CornerRadiusProperty, new Binding {
                Path = new PropertyPath(CornerRadiusProperty), Source = this
            });
            BindingOperations.SetBinding(behavior, WindowChromeBehavior.GlassFrameThicknessProperty, new Binding {
                Path = new PropertyPath(GlassFrameThicknessProperty), Source = this
            });
            behavior.UseAeroCaptionButtons = false;
            Interaction.GetBehaviors(this).Add(behavior);
        }
コード例 #5
0
        public async Task <bool?> ShowDialog(object dialogViewModel)
        {
            var window = Application.Current.MainWindow;

            if (window == null)
            {
                return(null);
            }
            if (!WindowChromeBehavior.GetIsEnable(window))
            {
                return(null);
            }

            WindowChromeBehavior.SetDialogContent(window, dialogViewModel);

            var dialogContentControl = window.FindChildrenFromTemplate <ContentControl>("PART_DialogContainer");

            if (dialogContentControl == null)
            {
                return(null);
            }
            await Task.Delay(100);

            var dialog = dialogContentControl.FindChildren <MetroDialog>().FirstOrDefault();

            if (dialog == null)
            {
                return(false);
            }
            await Task.Run(() =>
            {
                while (dialog.IsVisible)
                {
                }
            });

            return(dialog.DialogResult);
        }
コード例 #6
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     WindowChromeBehavior.SetDialogContent(Application.Current.MainWindow, null);
     this.DialogResult = false;
 }
コード例 #7
0
        /// <summary>
        /// Initializes the WindowChromeBehavior which is needed to render the custom WindowChrome.
        /// </summary>
        private void InitializeWindowChromeBehavior()
        {
            var behavior = new WindowChromeBehavior();

            Interaction.GetBehaviors(this).Add(behavior);
        }