public void ExpandStarsInBorder () { MyGrid grid = CreateGridWithChildren (); var parent = new Border (); parent.Child = grid; TestPanel.Width = 75; TestPanel.Height = 75; CreateAsyncTest (parent, () => { grid.CheckRowHeights ("#1", 12, 25, 38); grid.HorizontalAlignment = HorizontalAlignment.Left; grid.VerticalAlignment = VerticalAlignment.Center; parent.InvalidateSubtree (); }, () => { grid.CheckRowHeights ("#2", 12, 15, 15); grid.Width = 50; grid.Height = 50; parent.InvalidateSubtree (); }, () => { grid.CheckRowHeights ("#3", 8, 17, 25); grid.ClearValue (Grid.HorizontalAlignmentProperty); grid.ClearValue (Grid.VerticalAlignmentProperty); parent.InvalidateSubtree (); }, () => { grid.CheckRowHeights ("#4", 8, 17, 25); } ); }
public void ExpandInArrange_OutsideTree_BorderParent_FixedSize () { // We always expand star rows if we're not in the live tree var parent = new Border (); // Measure with infinity and check results. MyGrid grid = new MyGrid { Width = 200, Height = 200 }; grid.AddRows (Star); grid.AddColumns (Star); grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1); parent.Child = grid; parent.InvalidateSubtree (); parent.Measure (Infinity); grid.CheckMeasureArgs ("#1", new Size (200, 200)); grid.CheckMeasureResult ("#2", new Size (50, 50)); Assert.AreEqual (new Size (200, 200), grid.DesiredSize, "#3"); // When we pass in the desired size as the arrange arg, // the rows/cols use that as their height/width parent.Arrange (new Rect (0, 0, 1000, 10000)); grid.CheckArrangeArgs ("#4", grid.DesiredSize); grid.CheckArrangeResult ("#5", grid.DesiredSize); grid.CheckRowHeights ("#6", grid.DesiredSize.Height); grid.CheckColWidths ("#7", grid.DesiredSize.Width); // If we pass in twice the desired size, the rows/cols consume that too grid.Reset (); parent.Arrange (new Rect (0, 0, 5, 5)); grid.CheckMeasureArgs ("#8"); // No re-measuring grid.CheckArrangeArgs ("#9"); // No re-arranging grid.CheckArrangeResult ("#10"); grid.CheckRowHeights ("#11", 200); grid.CheckColWidths ("#12", 200); // If we measure with a finite size, the rows/cols still expand // to consume the available space grid.Reset (); parent.InvalidateSubtree (); parent.Measure (new Size (1000, 1000)); grid.CheckMeasureArgs ("#13", new Size (200, 200)); grid.CheckMeasureResult ("#14", new Size (50, 50)); Assert.AreEqual (new Size (200, 200), grid.DesiredSize, "#15"); // When we pass in the desired size as the arrange arg, // the rows/cols use that as their height/width parent.Arrange (new Rect (0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height)); grid.CheckArrangeArgs ("#16", grid.DesiredSize); grid.CheckArrangeResult ("#17", grid.DesiredSize); grid.CheckRowHeights ("#18", grid.DesiredSize.Height); grid.CheckColWidths ("#19", grid.DesiredSize.Width); }