summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/ViewRenderer.cs
blob: 148da1b30e6c51c7e0fe08466d02e302bd98a84c (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
using Windows.UI.Xaml;
using Windows.UI.Xaml.Automation;

#if WINDOWS_UWP

namespace Xamarin.Forms.Platform.UWP
#else

namespace Xamarin.Forms.Platform.WinRT
#endif
{
	public class ViewRenderer<TElement, TNativeElement> : VisualElementRenderer<TElement, TNativeElement> where TElement : View where TNativeElement : FrameworkElement
	{
		protected override void OnElementChanged(ElementChangedEventArgs<TElement> e)
		{
			base.OnElementChanged(e);

			if (e.NewElement != null)
			{
				UpdateBackgroundColor();
			}
		}

		protected override void SetAutomationId(string id)
		{
			if (Control == null)
			{
				base.SetAutomationId(id);
			}
			else
			{
				SetValue(AutomationProperties.AutomationIdProperty, $"{id}_Container");
				Control.SetValue(AutomationProperties.AutomationIdProperty, id);
			}
		}
	}
}