summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.ControlGallery.WindowsUniversal/CustomRenderers.cs
blob: 8d937d49fc4ee04f81adc601c755984d23d541b8 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
using Xamarin.Forms.Platform.UWP;

[assembly: ExportRenderer(typeof(Xamarin.Forms.Controls.Bugzilla42602.TextBoxView), typeof(Xamarin.Forms.ControlGallery.WindowsUniversal.TextBoxViewRenderer))]
namespace Xamarin.Forms.ControlGallery.WindowsUniversal
{
	public class TextBoxViewRenderer : BoxViewRenderer
	{
		Canvas m_Canvas;

		protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
		{
			base.OnElementChanged(e);

			ArrangeNativeChildren = true;

			if (m_Canvas != null)
				Children.Remove(m_Canvas);

			m_Canvas = new Canvas()
			{
				Width = 200,
				Height = 200,
				Background = new SolidColorBrush(Windows.UI.Color.FromArgb(0, 255, 255, 255)),
				IsHitTestVisible = false
			};

			Children.Add(m_Canvas);

			//ellipse
			Shape ellipse = new Ellipse()
			{
				Width = 100,
				Height = 100,
				Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)),

			};
			Canvas.SetLeft(ellipse, 0);
			Canvas.SetTop(ellipse, 0);
			m_Canvas.Children.Add(ellipse);

			//text
			TextBlock text = new TextBlock()
			{
				FontSize = 50,
				FontWeight = Windows.UI.Text.FontWeights.Normal,
				Text = "hello world",
				Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0))
			};
			Canvas.SetLeft(text, 0);
			Canvas.SetTop(text, 150);
			m_Canvas.Children.Add(text);
		}
	}
}