Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBret Johnson <bret.johnson@microsoft.com>2019-11-07 01:38:57 +0300
committerBret Johnson <bret.johnson@microsoft.com>2019-11-07 01:38:57 +0300
commit6a38f3b7f86964e4965f243d2dc3a5865da0a3ec (patch)
tree19f08e0ae621c0e284e0cfcd49d7e7a68c213887 /Xamarin.PropertyEditing.Windows
parent8790fdf0dad435fae13a3a3e79e0a066e83c7945 (diff)
Fix a11y bug 999307
Windows has the surprising behavior that when an automation group (like a group of combinable checkboxes) has a colon in the name, the group label is not read by the narrator. This causes a problem for the Android designer, which has property names like "app:layout_anchorGravity". We work around this by replacing the colon with a space in the group's automation name.
Diffstat (limited to 'Xamarin.PropertyEditing.Windows')
-rw-r--r--Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs b/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs
index f259bd9..8e61a68 100644
--- a/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs
+++ b/Xamarin.PropertyEditing.Windows/CombinablePredefinedValuesEditorControl.cs
@@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Automation;
+using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Windows
{
@@ -15,5 +17,24 @@ namespace Xamarin.PropertyEditing.Windows
DefaultStyleKeyProperty.OverrideMetadata (typeof (CombinablePredefinedValuesEditor), new FrameworkPropertyMetadata (typeof (CombinablePredefinedValuesEditor)));
FocusableProperty.OverrideMetadata (typeof(CombinablePredefinedValuesEditor), new FrameworkPropertyMetadata (false));
}
+
+ public override void OnApplyTemplate ()
+ {
+ base.OnApplyTemplate ();
+
+ // Windows has the surprising behavior that when an automation group (like a group of combinable checkboxes)
+ // has a colon in the name, the group label is not read by the narrator. This causes a problem for the Android
+ // designer, which has property names like "app:layout_anchorGravity". We work around this by replacing the
+ // colon with a space in the group's automation name.
+ var propertyPresenter = this.FindParent<PropertyPresenter> ();
+ if (propertyPresenter != null) {
+ var name = (propertyPresenter.DataContext as PropertyViewModel)?.Name;
+
+ if (name != null && name.Contains (":", StringComparison.Ordinal)) {
+ var automationName = name.Replace (':', ' ');
+ AutomationProperties.SetName (propertyPresenter, automationName);
+ }
+ }
+ }
}
}