示例#1
0
        public void TransformToVisual_Should_Work()
        {
            var child = new Decorator {
                Width = 100, Height = 100
            };
            var root = new TestRoot()
            {
                Child = child, Width = 400, Height = 400
            };

            root.Measure(Size.Infinity);
            root.Arrange(new Rect(new Point(), root.DesiredSize));

            var tr = child.TransformToVisual(root);

            Assert.NotNull(tr);

            var point = root.Bounds.TopLeft * tr;

            //child is centered (400 - 100)/2
            Assert.Equal(new Point(150, 150), point);
        }
示例#2
0
        public void TransformToVisual_With_NonInvertible_RenderTransform_Should_Work()
        {
            var child = new Decorator
            {
                Width           = 100,
                Height          = 100,
                RenderTransform = new ScaleTransform()
                {
                    ScaleX = 0, ScaleY = 0
                }
            };
            var root = new TestRoot()
            {
                Child = child, Width = 400, Height = 400
            };

            root.Measure(Size.Infinity);
            root.Arrange(new Rect(new Point(), root.DesiredSize));

            var tr = root.TransformToVisual(child);

            Assert.Null(tr);
        }