Measure() public method

Provides the behavior for the "measure" pass of the layout.
public Measure ( Size availableSize ) : Size
availableSize System.Windows.Size /// The available size that this object can give to child objects. Infinity can be specified as a /// value to indicate that the object will size to whatever content is available. ///
return System.Windows.Size
        public void ShouldArrangeVertically()
        {
            var canvas = GetCanvas();
            var arranger = new StackArranger(canvas.Children, Orientation.Vertical);

            var size = new Size(200, 800);
            List<ElementBounds> layout;
            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            layout[0].Bounds.Top.ShouldBe(0.0);
            layout[1].Bounds.Top.ShouldBe(100.0);
            layout[2].Bounds.Top.ShouldBe(200.0);

            foreach (FrameworkElement child in canvas.Children)
            {
                child.Margin = new Thickness(5);
            }

            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            layout[0].Bounds.Top.ShouldBe(0.0);
            layout[1].Bounds.Top.ShouldBe(110.0);
            layout[2].Bounds.Top.ShouldBe(220.0);
        }
        public void ShouldStretchToFit()
        {
            var canvas = GetCanvas();
            var arranger = new StackArranger(canvas.Children, Orientation.Vertical);

            var size = new Size(200, 800);
            List<ElementBounds> layout;
            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            // Not stretching.
            layout[0].Bounds.Width.ShouldBe(100.0);
            layout[1].Bounds.Width.ShouldBe(100.0);
            layout[2].Bounds.Width.ShouldBe(100.0);

            foreach (FrameworkElement child in canvas.Children)
            {
                child.Width = double.NaN;
            }

            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            layout[0].Bounds.Width.ShouldBe(200.0);
            layout[1].Bounds.Width.ShouldBe(200.0);
            layout[2].Bounds.Width.ShouldBe(200.0);

            // Horizontal
            arranger.Orientation = Orientation.Horizontal;
            size = new Size(800, 200);
            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            layout[0].Bounds.Height.ShouldBe(100.0);
            layout[1].Bounds.Height.ShouldBe(100.0);
            layout[2].Bounds.Height.ShouldBe(100.0);

            foreach (FrameworkElement child in canvas.Children)
            {
                child.Height = double.NaN;
            }

            arranger.Measure(size);
            arranger.ArrangeCalculate(size, out layout);

            layout[0].Bounds.Height.ShouldBe(200.0);
            layout[1].Bounds.Height.ShouldBe(200.0);
            layout[2].Bounds.Height.ShouldBe(200.0);
        }