示例#1
0
        private static LayoutTransformControl CreateWithChildAndMeasureAndTransform(
            double width,
            double height,
            Transform transform)
        {
            var lt = new LayoutTransformControl()
            {
                LayoutTransform = transform,
                Template        = new FuncControlTemplate <LayoutTransformControl>(
                    p => new ContentPresenter()
                {
                    Content = p.Content
                })
            };

            lt.Content = new Rectangle()
            {
                Width = width, Height = height
            };

            lt.ApplyTemplate();

            //we need to force create visual child
            //so the measure after is correct
            (lt.Presenter as ContentPresenter).UpdateChild();

            Assert.NotNull(lt.Presenter?.Child);

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

            return(lt);
        }
        private static LayoutTransformControl CreateWithChildAndMeasureAndTransform(
            double width,
            double height,
            Transform transform)
        {
            var lt = new LayoutTransformControl()
            {
                LayoutTransform = transform
            };

            lt.Child = new Rectangle()
            {
                Width = width, Height = height
            };

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

            return(lt);
        }
        private static LayoutTransformControl CreateWithChildAndMeasureAndTransform(
                                                double width,
                                                double height,
                                                Transform transform)
        {
            var lt = new LayoutTransformControl()
            {
                LayoutTransform = transform,
                Template = new FuncControlTemplate<LayoutTransformControl>(
                                p => new ContentPresenter() { Content = p.Content })
            };

            lt.Content = new Rectangle() { Width = width, Height = height };

            lt.ApplyTemplate();

            //we need to force create visual child
            //so the measure after is correct
            (lt.Presenter as ContentPresenter).UpdateChild();

            Assert.NotNull(lt.Presenter?.Child);

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

            return lt;
        }