Skip to content

Commit b959fbf

Browse files
committed
Updated carousel automation peer to improve returned name, and selection required being true
1 parent 411e39d commit b959fbf

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/Carousel/CarouselAutomationPeer.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections.Generic;
6-
using System.Linq;
76
using Microsoft.Toolkit.Uwp.UI.Controls;
7+
using Windows.UI.Xaml.Automation;
88
using Windows.UI.Xaml.Automation.Peers;
99
using Windows.UI.Xaml.Automation.Provider;
1010
using Windows.UI.Xaml.Controls;
@@ -33,7 +33,7 @@ public CarouselAutomationPeer(Carousel owner)
3333

3434
/// <summary>Gets a value indicating whether the UI Automation provider requires at least one child element to be selected.</summary>
3535
/// <returns>True if selection is required; otherwise, false.</returns>
36-
public bool IsSelectionRequired => false;
36+
public bool IsSelectionRequired => true;
3737

3838
private Carousel OwningCarousel
3939
{
@@ -82,24 +82,25 @@ protected override string GetClassNameCore()
8282
/// </returns>
8383
protected override string GetNameCore()
8484
{
85-
string name = string.Empty;
86-
87-
if (this.OwningCarousel != null)
85+
string name = AutomationProperties.GetName(this.OwningCarousel);
86+
if (!string.IsNullOrEmpty(name))
8887
{
89-
name = this.OwningCarousel.Name;
88+
return name;
9089
}
9190

92-
if (string.IsNullOrEmpty(name))
91+
name = this.OwningCarousel.Name;
92+
if (!string.IsNullOrEmpty(name))
9393
{
94-
name = base.GetNameCore();
94+
return name;
9595
}
9696

97-
if (string.IsNullOrEmpty(name))
97+
name = base.GetNameCore();
98+
if (!string.IsNullOrEmpty(name))
9899
{
99-
name = this.GetClassName();
100+
return name;
100101
}
101102

102-
return name;
103+
return string.Empty;
103104
}
104105

105106
/// <summary>

0 commit comments

Comments
 (0)