Ejemplo n.º 1
0
        public void Template_Result_Becomes_Visual_Child()
        {
            Control templateResult = new Control();

            var template = new FuncControlTemplate(_ =>
            {
                return templateResult;
            });

            var target = new TemplatedControl
            {
                Template = template,
            };

            target.Measure(new Size(100, 100));
            var children = target.GetVisualChildren().ToList();

            Assert.Equal(new[] { templateResult }, children);
        }
Ejemplo n.º 2
0
        public void Template_Gets_Executed_On_Measure()
        {
            bool executed = false;

            var template = new FuncControlTemplate(_ =>
            {
                executed = true;
                return new Control();
            });

            var target = new TemplatedControl
            {
                Template = template,
            };

            target.Measure(new Size(100, 100));

            Assert.True(executed);
        }
Ejemplo n.º 3
0
        public void TemplatedParent_Is_Set_On_Generated_Template()
        {
            Control templateResult = new Control();

            var template = new ControlTemplate(_ =>
            {
                return templateResult;
            });

            var target = new TemplatedControl
            {
                Template = template,
            };

            target.Measure(new Size(100, 100));

            Assert.Equal(target, templateResult.TemplatedParent);
        }