-
Notifications
You must be signed in to change notification settings - Fork 0
/
UwpAccessibilityEffect.cs
45 lines (39 loc) · 1.29 KB
/
UwpAccessibilityEffect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.ComponentModel;
using Windows.UI.Xaml.Automation;
using Windows.UI.Xaml.Automation.Peers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;
using XamarinFormsNarratorSample.Views.Effects;
[assembly: ResolutionGroupName("MyCompany")]
[assembly: ExportEffect(typeof(XamarinFormsNarratorSample.UWP.Effects.UwpAccessibilityEffect), "AddAccessibilityEffect")]
namespace XamarinFormsNarratorSample.UWP.Effects
{
public class UwpAccessibilityEffect : PlatformEffect
{
protected override void OnAttached()
{
UpdateName();
UpdateAccessibilityView();
}
protected override void OnDetached()
{
}
protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
{
if (args.PropertyName == AccessibilityEffect.AccessibilityLabelProperty.PropertyName) {
UpdateName();
}
else if (args.PropertyName == AccessibilityEffect.InAccessibleTreeProperty.PropertyName) {
UpdateAccessibilityView();
}
}
void UpdateName()
{
AutomationProperties.SetName(Control, AccessibilityEffect.GetAccessibilityLabel(Element) as string ?? string.Empty);
}
void UpdateAccessibilityView()
{
AutomationProperties.SetAccessibilityView(Control, AccessibilityEffect.GetInAccessibleTree(Element) ? AccessibilityView.Control : AccessibilityView.Raw);
}
}
}