Esempio n. 1
0
        public void Invalidating_Child_Should_Not_Invalidate_Parent()
        {
            var panel = new StackPanel();
            var child = new Border();
            panel.Children.Add(child);

            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            Assert.Equal(new Size(0, 0), panel.DesiredSize);

            child.Width = 100;
            child.Height = 100;

            Assert.True(panel.IsMeasureValid);
            Assert.False(child.IsMeasureValid);

            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Assert.Equal(new Size(0, 0), panel.DesiredSize);
        }
Esempio n. 2
0
        public void Removing_From_Parent_Should_Invalidate_Measure_Of_Control_And_Descendents()
        {
            var panel = new StackPanel();
            var child2 = new Border();
            var child1 = new Border { Child = child2 };
            panel.Children.Add(child1);

            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Assert.True(child1.IsMeasureValid);
            Assert.True(child2.IsMeasureValid);

            panel.Children.Remove(child1);
            Assert.False(child1.IsMeasureValid);
            Assert.False(child2.IsMeasureValid);
        }
Esempio n. 3
0
        public void Lays_Out_Children_Vertically()
        {
            var target = new StackPanel
            {
                Children = new Controls
                {
                    new Border { Height = 20, Width = 120 },
                    new Border { Height = 30 },
                    new Border { Height = 50 },
                }
            };

            target.Measure(Size.Infinity);
            target.Arrange(new Rect(target.DesiredSize));

            Assert.Equal(new Size(120, 100), target.Bounds.Size);
            Assert.Equal(new Rect(0, 0, 120, 20), target.Children[0].Bounds);
            Assert.Equal(new Rect(0, 20, 120, 30), target.Children[1].Bounds);
            Assert.Equal(new Rect(0, 50, 120, 50), target.Children[2].Bounds);
        }
Esempio n. 4
0
        public void Lays_Out_Children_Horizontally()
        {
            var target = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Children = new Controls
                {
                    new Border { Width = 20, Height = 120 },
                    new Border { Width = 30 },
                    new Border { Width = 50 },
                }
            };

            target.Measure(Size.Infinity);
            target.Arrange(new Rect(target.DesiredSize));

            Assert.Equal(new Size(100, 120), target.Bounds.Size);
            Assert.Equal(new Rect(0, 0, 20, 120), target.Children[0].Bounds);
            Assert.Equal(new Rect(20, 0, 30, 120), target.Children[1].Bounds);
            Assert.Equal(new Rect(50, 0, 50, 120), target.Children[2].Bounds);
        }