示例#1
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRows4 ()
		{
			// See how rowspan = 3 affects this with 5 rows.
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto);

			// Give first child a rowspan of 2
			grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 1, 1);
			grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 0, 1, 3, 1);

			CreateAsyncTest (grid,
				() => {
					// If an element spans across multiple rows and one of those rows
					// is already large enough to contain that element, it puts itself
					// entirely inside that row
					grid.CheckRowHeights ("#1", 53.33, 3.33, 3.33, 0, 0);
					grid.ChangeRow (1, 1);
				}, () => {
					// An 'auto' row which has no children whose rowspan/colspan
					// *ends* in that row has a height of zero
					grid.CheckRowHeights ("#2", 50, 20, 20, 20, 0);
					grid.ChangeRow (1, 2);
				}, () => {
					// If an element which spans multiple rows is the only element in
					// the rows it spans, it divides evenly between the rows it spans
					grid.CheckRowHeights ("#3", 50, 0, 20, 20, 20);

					grid.ChangeRow (1, 0);
					grid.ChangeRow (0, 1);
				}, () => {
					// If there are two auto rows beside each other and an element spans those
					// two rows, the total height is averaged between the two rows.
					grid.CheckRowHeights ("#4", 3.33, 53.33, 3.33, 0, 0);
				}
			);
		}
示例#2
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRows2 ()
		{
			// Start off with two elements in the first row with the smaller element having rowspan = 2
			// and see how rowspan affects the rendering.
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 2, 1);
			grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 0, 1, 1, 1);

			// Start off with both elements at row 1, and the smaller element having rowspan = 2
			CreateAsyncTest (grid,
				() => {
					// If an element spans across multiple rows and one of those rows
					// is already large enough to contain that element, it puts itself
					// entirely inside that row
					grid.CheckRowHeights ("#1", 60, 0, 0);

					grid.ChangeRow (1, 1);
				}, () => {
					// An 'auto' row which has no children whose rowspan/colspan
					// *ends* in that row has a height of zero
					grid.CheckRowHeights ("#2", 0, 60, 0);
					grid.ChangeRow (1, 2);
				}, () => {
					// If an element which spans multiple rows is the only element in
					// the rows it spans, it divides evenly between the rows it spans
					grid.CheckRowHeights ("#2", 25, 25, 60);
					grid.ChangeRow (1, 0);
					grid.ChangeRow (0, 1);
				}, () => {
					grid.CheckRowHeights ("#2", 60, 25, 25);
				}
			);
		}
示例#3
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRows3 ()
		{
			// Start off with two elements in the first row with the larger element having rowspan = 2
			// and see how rowspan affects the rendering.
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 1, 1);
			grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 0, 1, 2, 1);

			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 55, 5, 0);
					grid.ChangeRow (1, 1);
				}, () => {
					grid.CheckRowHeights ("#2", 50, 30, 30);
					grid.ChangeRow (1, 2);
				}, () => {
					grid.CheckRowHeights ("#3", 50, 0, 60);
					grid.ChangeRow (1, 0);
					grid.ChangeRow (0, 1);
				}, () => {
					grid.CheckRowHeights ("#3", 5, 55, 0);
				}
			);
		}
示例#4
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void SizeExceedsBounds2 ()
		{
			Grid grid = new Grid ();
			grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (50), MaxHeight = 60, MinHeight = 40 });
			grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (50), MaxHeight = 60, MinHeight = 40 });
			grid.AddChild (new MyContentControl (100, 1000), 0, 0, 0, 0);
			CreateAsyncTest (grid,
				() => {
					Assert.AreEqual (50, grid.RowDefinitions [0].ActualHeight, "#1");
					grid.ChangeRowSpan (0, 2);
				}, () => {
					Assert.AreEqual (50, grid.RowDefinitions [0].ActualHeight, "#1");
				}
			);
		}
示例#5
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRows ()
		{
			// This checks that rows expand to be large enough to hold the largest child
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto);

			grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 1, 1);
			grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 0, 1, 1, 1);

			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 60, 0);
					Grid.SetRow ((FrameworkElement) grid.Children [1], 1);
				}, () => {
					grid.CheckRowHeights ("#2", 50, 60);
				}
			);
		}
示例#6
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoCol_Empty_MinWidth ()
		{
			// Ensure MinWidth is respected in an empty Auto segment
			var grid = new Grid();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 1, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(10, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
示例#7
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void ExpandStarsInGrid ()
		{
			MyGrid grid = CreateGridWithChildren ();

			var parent = new Grid ();
			parent.AddRows (new GridLength (75));
			parent.AddColumns (new GridLength (75));
			parent.AddChild (grid, 0, 0, 1, 1);

			TestPanel.Width = 75;
			TestPanel.Height = 75;

			CreateAsyncTest (parent,
				() => {
					grid.CheckMeasureArgs ("#1a", new Size (12, 12), new Size (25, 12), new Size (38, 12),
												  new Size (12, 25), new Size (25, 25), new Size (38, 25),
												  new Size (12, 38), new Size (25, 38), new Size (38, 38));
					grid.CheckRowHeights ("#1", 12, 25, 38);

					grid.HorizontalAlignment = HorizontalAlignment.Left;
					grid.VerticalAlignment = VerticalAlignment.Center;
					parent.InvalidateSubtree ();
					grid.Reset ();
				}, () => {
					grid.CheckMeasureArgs ("#2a", new Size (12, 12), new Size (25, 12), new Size (38, 12),
												  new Size (12, 25), new Size (25, 25), new Size (38, 25),
												  new Size (12, 38), new Size (25, 38), new Size (38, 38));
					grid.CheckRowHeights ("#2", 12, 15, 15);

					grid.Width = 50;
					grid.Height = 50;
					parent.InvalidateSubtree ();
					grid.Reset ();
				}, () => {
					grid.CheckMeasureArgs ("#3a", new Size (8, 8), new Size (17, 8), new Size (25, 8),
												  new Size (8, 17), new Size (17, 17), new Size (25, 17),
												  new Size (8, 25), new Size (17, 25), new Size (25, 25));
					grid.CheckRowHeights ("#3", 8, 17, 25);

					grid.ClearValue (Grid.HorizontalAlignmentProperty);
					grid.ClearValue (Grid.VerticalAlignmentProperty);
					parent.InvalidateSubtree ();
					grid.Reset ();
				}, () => {
					grid.CheckMeasureArgs ("#4a", new Size (8, 8), new Size (17, 8), new Size (25, 8),
												  new Size (8, 17), new Size (17, 17), new Size (25, 17),
												  new Size (8, 25), new Size (17, 25), new Size (25, 25));
					grid.CheckRowHeights ("#4", 8, 17, 25);
				}
			);
		}
示例#8
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void StarStarRows_LimitedHeight_RowSpan_InfiniteSpace()
		{
			var grid = new Grid();
			grid.RowDefinitions.Add(new RowDefinition { Height = Star });
			grid.RowDefinitions.Add(new RowDefinition { MaxHeight = 20, Height = Star });

			var child1 = ContentControlWithChild();
			var child2 = ContentControlWithChild();
			(child1.Content as FrameworkElement).Height = 50;
			(child2.Content as FrameworkElement).Height = 70;
			grid.AddChild(child1, 0, 0, 1, 1);
			grid.AddChild(child2, 0, 0, 2, 1);

			grid.Measure(Infinity);
			Assert.AreEqual(Infinity, child1.MeasureOverrideArg, "#1");
			Assert.AreEqual(Infinity, child2.MeasureOverrideArg, "#2");
			Assert.AreEqual(new Size (50, 70), grid.DesiredSize, "#3");
		}
示例#9
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void StarRow_AutoStarCol_LimitedWidth()
		{
			var g = new Grid();
			var child = ContentControlWithChild();

			g.RowDefinitions.Add(new RowDefinition { Height = Star });
			g.ColumnDefinitions.Add(new ColumnDefinition { Width = Auto });
			g.ColumnDefinitions.Add(new ColumnDefinition { Width = Star, MaxWidth = 20 });
			g.AddChild(child, 0, 0, 1, 1);

			g.Measure(new Size(100, 100));
			Assert.AreEqual(new Size(inf, 100), child.MeasureOverrideArg, "#1");
		}
示例#10
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void MeasureAutoAndFixedRows ()
		{
			Grid grid = new Grid { };

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (new GridLength (20), new GridLength (20));
			grid.AddChild (new MyContentControl (50, 50), 0, 1, 2, 1);

			grid.Measure (Infinity);
			grid.CheckRowHeights ("#1", 20, 20);
			grid.CheckMeasureSizes ("#2", new Size (50, 40));
			Assert.AreEqual (new Size (100, 40), grid.DesiredSize, "#3");

			grid.RowDefinitions [0].Height = new GridLength (30);
			grid.Measure (Infinity);
			grid.CheckRowHeights ("#4", 30, 20);
			grid.CheckMeasureSizes ("#5", new Size (50, 50));
			Assert.AreEqual (new Size (100, 50), grid.DesiredSize, "#6");

			grid.RowDefinitions.Insert (0, new RowDefinition { Height = GridLength.Auto });
			grid.Measure (Infinity);
			grid.CheckRowHeights ("#7", double.PositiveInfinity, 30, 20);
			grid.CheckMeasureSizes ("#8", new Size (50, double.PositiveInfinity));
			Assert.AreEqual (new Size (100, 70), grid.DesiredSize, "#9");

			grid.Children.Clear ();
			grid.AddChild (new MyContentControl (50, 150), 0, 1, 2, 1);
			grid.Measure (Infinity);
			grid.CheckDesired ("#13", new Size (50, 150));
			grid.CheckRowHeights ("#10", double.PositiveInfinity, 30, 20);
			grid.CheckMeasureSizes ("#11", new Size (50, double.PositiveInfinity));
			grid.CheckMeasureResult ("#12", new Size (50, 150));
			Assert.AreEqual (new Size (100, 170), grid.DesiredSize, "#12");
		}
示例#11
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void StarStarRows_LimitedHeight_RowSpan_ExactSpace()
		{
			var grid = new Grid();
			grid.RowDefinitions.Add(new RowDefinition { Height = Star });
			grid.RowDefinitions.Add(new RowDefinition { MaxHeight = 20, Height = Star });

			var child1 = ContentControlWithChild();
			var child2 = ContentControlWithChild();
			(child1.Content as FrameworkElement).Height = 50;
			(child2.Content as FrameworkElement).Height = 70;

			grid.AddChild(child1, 0, 0, 1, 1);
			grid.AddChild(child2, 0, 0, 2, 1);

			Action<Size> sized = delegate {
				Assert.AreEqual(50, grid.RowDefinitions[0].ActualHeight, "#row 0 sized");
				Assert.AreEqual(20, grid.RowDefinitions[1].ActualHeight, "#row 1 sized");
			};

			child1.MeasureHook = sized;
			child2.MeasureHook = sized;
			grid.Measure(new Size(70, 70));

			// The row definitions have already been fully sized before the first
			// call to measure a child
			Assert.AreEqual(new Size(70, 50), child1.MeasureOverrideArg, "#1");
			Assert.AreEqual(new Size(70, 70), child2.MeasureOverrideArg, "#2");
			Assert.AreEqual(new Size(50, 70), grid.DesiredSize, "#3");
		}
示例#12
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void MeasureAutoRows4 ()
		{
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 30), 0, 1, 3, 1);
			grid.AddChild (new MyContentControl (50, 90), 0, 1, 1, 1);
			grid.AddChild (new MyContentControl (50, 50), 0, 1, 2, 1);

			grid.AddChild (new MyContentControl (50, 70), 1, 1, 4, 1);
			grid.AddChild (new MyContentControl (50, 120), 1, 1, 2, 1);
			grid.AddChild (new MyContentControl (50, 30), 2, 1, 3, 1);

			grid.AddChild (new MyContentControl (50, 10), 3, 1, 1, 1);
			grid.AddChild (new MyContentControl (50, 50), 3, 1, 2, 1);
			grid.AddChild (new MyContentControl (50, 80), 3, 1, 2, 1);

			grid.AddChild (new MyContentControl (50, 20), 4, 1, 1, 1);

			CreateAsyncTest (grid, () => {
				grid.CheckRowHeights ("#1", 90, 60, 60, 35, 45);
			});
		}
示例#13
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void MeasureAutoRows3 ()
		{
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 50), 0, 1, 2, 1);
			grid.AddChild (new MyContentControl (50, 60), 1, 1, 1, 1);
			grid.AddChild (new MyContentControl (50, 70), 0, 1, 3, 1);

			CreateAsyncTest (grid, () => {
				grid.CheckRowHeights ("#1", 3.33, 63.33, 3.33);
			});
		}
示例#14
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void MeasureMaxAndMin3 ()
		{
			Grid g = new Grid ();
			var child = new MyContentControl (50, 50);
			g.AddColumns (new GridLength (50));
			g.AddRows (new GridLength (20), new GridLength (20));
			g.AddChild (child, 0, 0, 2, 2);

			g.RowDefinitions [0].MaxHeight = 5;
			g.RowDefinitions [1].MaxHeight = 30;

			CreateAsyncTest (g,
				() => {
					var arg = child.MeasureOverrideArg;
					Assert.AreEqual (25, arg.Height, "#1");
					g.RowDefinitions [0].MaxHeight = 10;
				}, () => {
					var arg = child.MeasureOverrideArg;
					Assert.AreEqual (30, arg.Height, "#2");
					g.RowDefinitions [0].MaxHeight = 20;
				}, () => {
					var arg = child.MeasureOverrideArg;
					Assert.AreEqual (40, arg.Height, "#3");
				}
			);
		}
示例#15
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRows5 ()
		{
			Grid grid = new Grid ();

			grid.AddColumns (new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 3, 1);
			grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 1, 0, 3, 1);

			// When calculating the heights of automatic rows, the children added to the grid
			// distribute their height in the opposite order in which they were added.
			CreateAsyncTest (grid,
				() => {
					// Here the element with height 60 distributes its height first
					grid.CheckRowHeights ("#1", 3.33, 23.33, 23.33, 20, 0);
					grid.ChangeRow (1, 1);

					grid.ChangeRow (0, 1);
					grid.ChangeRow (1, 0);
				}, () => {
					// Reversing the rows does not stop the '60' element from
					// Distributing its height first
					grid.CheckRowHeights ("#2", 20, 23.33, 23.33, 3.33, 0);

					// Now reverse the order in which the elements are added so that
					// the '50' element distributes first.
					grid.Children.Clear ();
					grid.AddChild (new LayoutPoker { Width = 50, Height = 60 }, 1, 0, 3, 1);
					grid.AddChild (new LayoutPoker { Width = 50, Height = 50 }, 0, 0, 3, 1);

				}, () => {
					grid.CheckRowHeights ("#3", 16.66, 25.55, 25.55, 8.88, 0);
					grid.ChangeRow (1, 1);

					grid.ChangeRow (0, 1);
					grid.ChangeRow (1, 0);
				}, () => {
					grid.CheckRowHeights ("#4", 16.66, 25.55, 25.55, 8.88, 0);
				}
			);
		}
示例#16
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoRow_StarCol()
		{
			var g = new Grid();
			var child = ContentControlWithChild ();
			g.RowDefinitions.Add(new RowDefinition { Height = Star });
			g.RowDefinitions.Add(new RowDefinition { Height = Star, MaxHeight = 20 });

			g.AddChild(child, 0, 0, 1, 1);
			g.Measure(new Size(100, 100));
			Assert.AreEqual(new Size(100, 80), child.MeasureOverrideArg, "#1");
		}
示例#17
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoAndFixedRows3 ()
		{
			Grid grid = new Grid { Width = 10, Height = 10 };
			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (new GridLength (20), new GridLength (20));

			grid.AddChild (new MyContentControl (50, 50), 0, 1, 2, 1);

			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 20, 20);
					grid.RowDefinitions.Insert (0, new RowDefinition { Height = GridLength.Auto });
				}, () => {
					grid.CheckRowHeights ("#2", 0, 50, 20);
					grid.RowDefinitions [1].MaxHeight = 35;
				}, () => {
					grid.CheckRowHeights ("#3", 15, 35, 20);
					grid.RowDefinitions [1].MaxHeight = 20;
					grid.ChangeRowSpan (0, 4);
				}, () => {
					grid.CheckRowHeights ("#4", 0, 20, 30);
					grid.AddRows (new GridLength (20));
				}, () => {
					grid.CheckRowHeights ("#5", 0, 20, 20, 20);
				}
			);
		}
示例#18
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void RowspanAutoTest ()
		{
			// This test demonstrates the following rules:
			// 1) Elements with RowSpan/ColSpan == 1 distribute their height first
			// 2) The rest of the elements distribute height in LIFO order
			Grid grid = new Grid ();
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);
			grid.AddColumns (new GridLength (50));

			var child50 = new MyContentControl (50, 50);
			var child60 = new MyContentControl (50, 60);

			grid.AddChild (child50, 0, 0, 1, 1);
			grid.AddChild (child60, 0, 0, 1, 1);

			CreateAsyncTest (grid,
				() => {
					// Check the initial values
					grid.CheckRowHeights ("#1", 60, 0, 0);

					// Now make the smaller element use rowspan = 2
					Grid.SetRowSpan (child50, 2);
				}, () => {
					grid.CheckRowHeights ("#2", 60, 0, 0);

					// Then make the larger element us rowspan = 2
					Grid.SetRowSpan (child50, 1);
					Grid.SetRowSpan (child60, 2);
				}, () => {
					grid.CheckRowHeights ("#3", 55, 5, 0);

					// Swap the order in which they are added to the grid
					grid.Children.Clear ();
					grid.AddChild (child60, 0, 0, 2, 0);
					grid.AddChild (child50, 0, 0, 1, 0);
				}, () => {
					// Swapping the order has no effect here
					grid.CheckRowHeights ("#4", 55, 5, 0);

					// Then give both rowspan = 2
					Grid.SetRowSpan (child50, 2);
				}, () => {
					grid.CheckRowHeights ("#5", 30, 30, 0);

					// Finally give the larger element rowspan = 3
					Grid.SetRowSpan (child60, 3);
				}, () => {
					grid.CheckRowHeights ("#6", 28.333, 28.333, 3.333);

					// Swap the order in which the elements are added again
					grid.Children.Clear ();
					grid.AddChild (child50, 0, 0, 2, 0);
					grid.AddChild (child60, 0, 0, 3, 0);
				}, () => {
					grid.CheckRowHeights ("#7", 25, 25, 20);
				}
			);
		}
示例#19
0
文件: GridTestAuto.cs 项目: dfr0/moon
		public void AutoCol_MinWidth ()
		{
			var grid = new Grid ();
			grid.AddColumns(Auto, Star);
			grid.ColumnDefinitions[0].MinWidth = 10;
			grid.AddChild(ContentControlWithChild(), 0, 0, 0, 0);

			CreateAsyncTest(grid, () => {
				grid.UpdateLayout();
				Assert.AreEqual(50, grid.ColumnDefinitions[0].ActualWidth, "#1");
			});
		}
    private EitherControl InitView(out TextBox usernameBox, out System.Windows.Forms.TextBox passwordBox)
    {
      var grid = new Grid { Background = SystemColors.ControlBrush };

      var colDef1 = new ColumnDefinition { Width = GridLength.Auto };
      var colDef2 = new ColumnDefinition { Width = GridLength.Auto, MinWidth = AVATAR_SIZE };
      grid.ColumnDefinitions.Add(colDef1);
      grid.ColumnDefinitions.Add(colDef2);

      // Define the Rows
      var rowDef1 = new RowDefinition { Height = GridLength.Auto };
      var rowDef2 = new RowDefinition { Height = GridLength.Auto };
      var rowDef3 = new RowDefinition { Height = GridLength.Auto };
      var rowDef4 = new RowDefinition { Height = GridLength.Auto, MinHeight = AVATAR_SIZE, };
      grid.RowDefinitions.Add(rowDef1);
      grid.RowDefinitions.Add(rowDef2);
      grid.RowDefinitions.Add(rowDef3);
      grid.RowDefinitions.Add(rowDef4);

      var header = new Label { Content = "GitHub access" };
      Grid.SetColumn(header, 0);
      Grid.SetColumnSpan(header, 2);
      Grid.SetRow(header, 0);

      var usernameLabel = new Label { Content = "Username:"******"Password:" };
      Grid.SetColumn(passwordLabel, 0);
      Grid.SetRow(passwordLabel, 2);

      passwordBox = new System.Windows.Forms.TextBox { UseSystemPasswordChar = true };
      var passwordHost = new WindowsFormsHost { Child =  passwordBox };
      Grid.SetColumn(passwordHost, 1);
      Grid.SetRow(passwordHost, 2);

      var imageBox = new Image { Width = AVATAR_SIZE, Margin = new Thickness(0, 10, 0, 10) };

      // Create source
      var image = new BitmapImage();
      // BitmapImage.UriSource must be in a BeginInit/EndInit block
      image.BeginInit();
      image.UriSource = new Uri(GetAvatar());
      image.DecodePixelWidth = AVATAR_SIZE;
      image.EndInit();
      //set image source
      imageBox.Source = image;
      Grid.SetColumn(imageBox, 1);
      Grid.SetRow(imageBox, 3);

      grid.AddChild(header);
      grid.AddChild(usernameLabel);
      grid.AddChild(usernameBox);
      grid.AddChild(passwordLabel);
      grid.AddChild(passwordHost);
      grid.AddChild(imageBox);

      return grid;
    }