From 0ac40efffc036f74f89929a2c20db4a90c99d7c1 Mon Sep 17 00:00:00 2001
From: michael-hawker <24302614+michael-hawker@users.noreply.github.com>
Date: Fri, 4 Mar 2022 16:42:09 -0800
Subject: [PATCH] Update AutomationPeer naming and types to be generalized
(untested still with new base class)
---
.../Sizers/ContentSizer/ContentSizer.cs | 11 ----------
.../Sizers/SizerAutomationPeer.cs | 20 +++++++++----------
.../Sizers/SizerBase.cs | 13 ++++++++++--
.../UI/Controls/Test_ContentSizer.cs | 2 +-
4 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/ContentSizer/ContentSizer.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/ContentSizer/ContentSizer.cs
index 203835e3aa2..bcaba6a0272 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/ContentSizer/ContentSizer.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/ContentSizer/ContentSizer.cs
@@ -2,9 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Controls
@@ -14,13 +11,5 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
///
public partial class ContentSizer : SizerBase
{
- ///
- /// Creates AutomationPeer ()
- ///
- /// An automation peer for this .
- protected override AutomationPeer OnCreateAutomationPeer()
- {
- return new ContentSizerAutomationPeer(this);
- }
}
}
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerAutomationPeer.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerAutomationPeer.cs
index ad9d10d3513..c6e0170cd3e 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerAutomationPeer.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerAutomationPeer.cs
@@ -8,29 +8,27 @@
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
{
- // TODO: Make this generalize for SizerBase?
-
///
- /// Defines a framework element automation peer for the control.
+ /// Defines a framework element automation peer for the controls.
///
- public class ContentSizerAutomationPeer : FrameworkElementAutomationPeer
+ public class SizerAutomationPeer : FrameworkElementAutomationPeer
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
- /// The that is associated with this .
+ /// The that is associated with this .
///
- public ContentSizerAutomationPeer(ContentSizer owner)
+ public SizerAutomationPeer(SizerBase owner)
: base(owner)
{
}
- private ContentSizer OwningContentSizer
+ private SizerBase OwningSizer
{
get
{
- return Owner as ContentSizer;
+ return Owner as SizerBase;
}
}
@@ -55,13 +53,13 @@ protected override string GetClassNameCore()
///
protected override string GetNameCore()
{
- string name = AutomationProperties.GetName(this.OwningContentSizer);
+ string name = AutomationProperties.GetName(this.OwningSizer);
if (!string.IsNullOrEmpty(name))
{
return name;
}
- name = this.OwningContentSizer.Name;
+ name = this.OwningSizer.Name;
if (!string.IsNullOrEmpty(name))
{
return name;
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs
index 49c60e661cd..1bff9578481 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs
@@ -2,11 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Windows.UI.Core;
+using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
using Windows.UI.Xaml;
+using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Markup;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
@@ -75,6 +75,15 @@ public SizerBase()
this.DefaultStyleKey = typeof(SizerBase);
}
+ ///
+ /// Creates AutomationPeer ()
+ ///
+ /// An automation peer for this .
+ protected override AutomationPeer OnCreateAutomationPeer()
+ {
+ return new SizerAutomationPeer(this);
+ }
+
///
protected override void OnApplyTemplate()
{
diff --git a/UnitTests/UnitTests.UWP/UI/Controls/Test_ContentSizer.cs b/UnitTests/UnitTests.UWP/UI/Controls/Test_ContentSizer.cs
index 6cef47822f8..0d9f500ab0f 100644
--- a/UnitTests/UnitTests.UWP/UI/Controls/Test_ContentSizer.cs
+++ b/UnitTests/UnitTests.UWP/UI/Controls/Test_ContentSizer.cs
@@ -22,7 +22,7 @@ public void ShouldConfigureContentSizerAutomationPeer()
const string name = "ContentSizer";
var contentSizer = new ContentSizer();
- var contentSizerAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(contentSizer) as ContentSizerAutomationPeer;
+ var contentSizerAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(contentSizer) as SizerAutomationPeer;
Assert.IsNotNull(contentSizerAutomationPeer, "Verify that the AutomationPeer is ContentSizerAutomationPeer.");