Esempio n. 1
0
        public void Should_Remove_Old_Child_From_LogicalChildren_On_ContentChanged_OutsideTemplate()
        {
            var target = new ContentPresenter
            {
                ContentTemplate =
                    new FuncDataTemplate <string>(t => new ContentControl()
                {
                    Content = t
                }, false)
            };

            target.Content = "foo";

            target.UpdateChild();

            var foo = target.Child as ContentControl;

            Assert.NotNull(foo);

            var logicalChildren = target.GetLogicalChildren();

            Assert.Equal(1, logicalChildren.Count());

            target.Content = "bar";
            target.UpdateChild();

            Assert.Equal(null, foo.Parent);

            logicalChildren = target.GetLogicalChildren();

            Assert.Equal(1, logicalChildren.Count());
            Assert.NotEqual(foo, logicalChildren.First());
        }
Esempio n. 2
0
        public void Should_Add_Child_To_Own_LogicalChildren_Outside_Template()
        {
            var content = new Border();
            var target  = new ContentPresenter {
                Content = content
            };

            target.UpdateChild();

            var logicalChildren = target.GetLogicalChildren();

            Assert.Equal(1, logicalChildren.Count());
            Assert.Equal(content, logicalChildren.First());
        }
Esempio n. 3
0
        public void Should_Add_Child_To_Own_LogicalChildren_Standalone()
        {
            var content = new Border();
            var target  = new ContentPresenter {
                Content = content
            };

            target.UpdateChild();

            var logicalChildren = target.GetLogicalChildren();

            Assert.Single(logicalChildren);
            Assert.Equal(content, logicalChildren.First());
        }