summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1097.cs
blob: 7b67e1e21ba3a21871dd2a8476a91955bbbfa8e1 (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
58
59
60
using System;

using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 1097, "Not resizing elements on rotation", PlatformAffected.iOS)]
	public class Issue1097 : ContentPage
	{
		public Issue1097 ()
		{
			Grid grid = new Grid {
				RowSpacing = 0,
				ColumnSpacing = 0,
			};

			grid.AddRowDef(count: 2);
			grid.AddColumnDef(count : 2);

			grid.Children.Add(new BoxView() { Color = Color.Red });

			var v2 = new BoxView { Color = Color.Blue };
			Grid.SetColumn(v2, 1);
			grid.Children.Add(v2);

			var v3 = new BoxView { Color = Color.Green };
			Grid.SetRow(v3, 1);
			grid.Children.Add(v3);

			var v4 = new BoxView { Color = Color.Purple };
			Grid.SetRow(v4, 1);
			Grid.SetColumn(v4, 1);
			grid.Children.Add(v4);

			Content = grid;
		}
	}
	public static class GridExtensions
	{
		public static void AddRowDef(this Grid grid, double size = 1, GridUnitType type = GridUnitType.Star, int count = 1)
		{
			for (int i = 0; i < count; i++) {
				grid.RowDefinitions.Add(new RowDefinition() {
					Height = new GridLength(size, type)
				});
			}
		}

		public static void AddColumnDef(this Grid grid, double size = 1, GridUnitType type = GridUnitType.Star, int count = 1)
		{
			for (int i = 0; i < count; i++) {
				grid.ColumnDefinitions.Add(new ColumnDefinition() {
					Width = new GridLength(size, type)
				});
			}
		}
	}
}