summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/ViewContainers/ViewContainer.cs
blob: f12a00302409ccade5d4d18d88d245d5c3b55bfd (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
41
42
43
44
using System;
using System.Linq.Expressions;

namespace Xamarin.Forms.Controls
{
	internal enum ViewLayoutType
	{
		Normal,
		Layered
	}

	internal class ViewContainer<T> 
		where T : View
	{

		public Label TitleLabel { get; private set; }
		public Label BoundsLabel { get; private set; }
		public T View { get; private set; }

		// May want to override the container layout in subclasses
		public StackLayout ContainerLayout { get; protected set; }

		public ViewContainer (Enum formsMember, T view)
		{
			view.AutomationId = formsMember + "VisualElement";
			View = view;
			
			TitleLabel = new Label {
				Text = formsMember + " View"
			};

			BoundsLabel = new Label {
				BindingContext = new MultiBindingHack (view)
			};
			BoundsLabel.SetBinding (Label.TextProperty, "LabelWithBounds");

			ContainerLayout = new StackLayout {
				AutomationId = formsMember + "Container", 
				Padding = 10,
				Children = { TitleLabel, BoundsLabel, view }
			};
		}
	}
}