Skip to content

Commit 95006fb

Browse files
Update AutomationPeer naming and types to be generalized (untested still with new base class)
1 parent 2a1f4d7 commit 95006fb

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/ContentSizer/ContentSizer.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
6-
using Windows.UI.Xaml;
7-
using Windows.UI.Xaml.Automation.Peers;
85
using Windows.UI.Xaml.Controls;
96

107
namespace Microsoft.Toolkit.Uwp.UI.Controls
@@ -14,13 +11,5 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
1411
/// </summary>
1512
public partial class ContentSizer : SizerBase
1613
{
17-
/// <summary>
18-
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
19-
/// </summary>
20-
/// <returns>An automation peer for this <see cref="ContentSizer"/>.</returns>
21-
protected override AutomationPeer OnCreateAutomationPeer()
22-
{
23-
return new ContentSizerAutomationPeer(this);
24-
}
2514
}
2615
}

Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerAutomationPeer.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,27 @@
88

99
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
1010
{
11-
// TODO: Make this generalize for SizerBase?
12-
1311
/// <summary>
14-
/// Defines a framework element automation peer for the <see cref="ContentSizer"/> control.
12+
/// Defines a framework element automation peer for the <see cref="SizerBase"/> controls.
1513
/// </summary>
16-
public class ContentSizerAutomationPeer : FrameworkElementAutomationPeer
14+
public class SizerAutomationPeer : FrameworkElementAutomationPeer
1715
{
1816
/// <summary>
19-
/// Initializes a new instance of the <see cref="ContentSizerAutomationPeer"/> class.
17+
/// Initializes a new instance of the <see cref="SizerAutomationPeer"/> class.
2018
/// </summary>
2119
/// <param name="owner">
22-
/// The <see cref="ContentSizer" /> that is associated with this <see cref="T:Windows.UI.Xaml.Automation.Peers.ContentSizerAutomationPeer" />.
20+
/// The <see cref="SizerBase" /> that is associated with this <see cref="SizerAutomationPeer" />.
2321
/// </param>
24-
public ContentSizerAutomationPeer(ContentSizer owner)
22+
public SizerAutomationPeer(SizerBase owner)
2523
: base(owner)
2624
{
2725
}
2826

29-
private ContentSizer OwningContentSizer
27+
private SizerBase OwningSizer
3028
{
3129
get
3230
{
33-
return Owner as ContentSizer;
31+
return Owner as SizerBase;
3432
}
3533
}
3634

@@ -55,13 +53,13 @@ protected override string GetClassNameCore()
5553
/// </returns>
5654
protected override string GetNameCore()
5755
{
58-
string name = AutomationProperties.GetName(this.OwningContentSizer);
56+
string name = AutomationProperties.GetName(this.OwningSizer);
5957
if (!string.IsNullOrEmpty(name))
6058
{
6159
return name;
6260
}
6361

64-
name = this.OwningContentSizer.Name;
62+
name = this.OwningSizer.Name;
6563
if (!string.IsNullOrEmpty(name))
6664
{
6765
return name;

Microsoft.Toolkit.Uwp.UI.Controls.Layout/Sizers/SizerBase.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using Windows.UI.Core;
5+
using Microsoft.Toolkit.Uwp.UI.Automation.Peers;
66
using Windows.UI.Xaml;
7+
using Windows.UI.Xaml.Automation.Peers;
78
using Windows.UI.Xaml.Controls;
89
using Windows.UI.Xaml.Input;
9-
using Windows.UI.Xaml.Markup;
1010

1111
namespace Microsoft.Toolkit.Uwp.UI.Controls
1212
{
@@ -75,6 +75,15 @@ public SizerBase()
7575
this.DefaultStyleKey = typeof(SizerBase);
7676
}
7777

78+
/// <summary>
79+
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
80+
/// </summary>
81+
/// <returns>An automation peer for this <see cref="SizerBase"/>.</returns>
82+
protected override AutomationPeer OnCreateAutomationPeer()
83+
{
84+
return new SizerAutomationPeer(this);
85+
}
86+
7887
/// <inheritdoc/>
7988
protected override void OnApplyTemplate()
8089
{

UnitTests/UnitTests.UWP/UI/Controls/Test_ContentSizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void ShouldConfigureContentSizerAutomationPeer()
2222
const string name = "ContentSizer";
2323

2424
var contentSizer = new ContentSizer();
25-
var contentSizerAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(contentSizer) as ContentSizerAutomationPeer;
25+
var contentSizerAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(contentSizer) as SizerAutomationPeer;
2626

2727
Assert.IsNotNull(contentSizerAutomationPeer, "Verify that the AutomationPeer is ContentSizerAutomationPeer.");
2828

0 commit comments

Comments
 (0)