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

CombinablePredefinedValuesEditorControl.cs « Xamarin.PropertyEditing.Windows - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e61a687e67dcbbf5335fe66c25c4e80af411b9f (plain)
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
using System;
using System.Collections.Generic;
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
{
	internal class CombinablePredefinedValuesEditor
		: PropertyEditorControl
	{
		static CombinablePredefinedValuesEditor ()
		{
			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);
				}
			}
		}
	}
}