From 23a6517a6b064cecda957be0eeb768074bf76823 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 8 Jul 2022 22:36:40 +0200 Subject: [PATCH] Refactored CaptionButtons. Converted buttons to be actual buttons instead of `Panel`s so that we get correct button behavior, i.e. the possibility to cancel by releasing the mouse outside the button. --- .../Chrome/CaptionButtons.cs | 27 ++-- .../Controls/CaptionButtons.xaml | 152 +++++++++++------- 2 files changed, 108 insertions(+), 71 deletions(-) diff --git a/src/Avalonia.Controls/Chrome/CaptionButtons.cs b/src/Avalonia.Controls/Chrome/CaptionButtons.cs index d5923a8b37..6d7e542bb2 100644 --- a/src/Avalonia.Controls/Chrome/CaptionButtons.cs +++ b/src/Avalonia.Controls/Chrome/CaptionButtons.cs @@ -8,10 +8,10 @@ namespace Avalonia.Controls.Chrome /// /// Draws window minimize / maximize / close buttons in a when managed client decorations are enabled. /// - [TemplatePart("PART_CloseButton", typeof(Panel))] - [TemplatePart("PART_RestoreButton", typeof(Panel))] - [TemplatePart("PART_MinimiseButton", typeof(Panel))] - [TemplatePart("PART_FullScreenButton", typeof(Panel))] + [TemplatePart("PART_CloseButton", typeof(Button))] + [TemplatePart("PART_RestoreButton", typeof(Button))] + [TemplatePart("PART_MinimiseButton", typeof(Button))] + [TemplatePart("PART_FullScreenButton", typeof(Button))] [PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")] public class CaptionButtons : TemplatedControl { @@ -88,18 +88,15 @@ namespace Avalonia.Controls.Chrome { base.OnApplyTemplate(e); - var closeButton = e.NameScope.Get("PART_CloseButton"); - var restoreButton = e.NameScope.Get("PART_RestoreButton"); - var minimiseButton = e.NameScope.Get("PART_MinimiseButton"); - var fullScreenButton = e.NameScope.Get("PART_FullScreenButton"); + var closeButton = e.NameScope.Get + + + + + + + + + + +