From 4edb8a5fec1c61d8f60562c25d8f2df0dfde6e27 Mon Sep 17 00:00:00 2001 From: robloo Date: Sat, 13 May 2023 13:02:57 -0400 Subject: [PATCH] Use template part name constants in CaptionButtons --- .../Chrome/CaptionButtons.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Avalonia.Controls/Chrome/CaptionButtons.cs b/src/Avalonia.Controls/Chrome/CaptionButtons.cs index 7a5bab33f4..237fa87968 100644 --- a/src/Avalonia.Controls/Chrome/CaptionButtons.cs +++ b/src/Avalonia.Controls/Chrome/CaptionButtons.cs @@ -8,13 +8,18 @@ namespace Avalonia.Controls.Chrome /// /// Draws window minimize / maximize / close buttons in a when managed client decorations are enabled. /// - [TemplatePart("PART_CloseButton", typeof(Button))] - [TemplatePart("PART_RestoreButton", typeof(Button))] - [TemplatePart("PART_MinimizeButton", typeof(Button))] - [TemplatePart("PART_FullScreenButton", typeof(Button))] + [TemplatePart(PART_CloseButton, typeof(Button))] + [TemplatePart(PART_RestoreButton, typeof(Button))] + [TemplatePart(PART_MinimizeButton, typeof(Button))] + [TemplatePart(PART_FullScreenButton, typeof(Button))] [PseudoClasses(":minimized", ":normal", ":maximized", ":fullscreen")] public class CaptionButtons : TemplatedControl { + private const string PART_CloseButton = "PART_CloseButton"; + private const string PART_RestoreButton = "PART_RestoreButton"; + private const string PART_MinimizeButton = "PART_MinimizeButton"; + private const string PART_FullScreenButton = "PART_FullScreenButton"; + private Button? _restoreButton; private IDisposable? _disposables; @@ -95,10 +100,10 @@ namespace Avalonia.Controls.Chrome { base.OnApplyTemplate(e); - var closeButton = e.NameScope.Get