public void Control_Should_Unregister_With_NameScope()
        {
            var root = new TestRoot
            {
                Child = new Border
                {
                    Name = "foo",
                    Child = new Border
                    {
                        Name = "bar",
                    }
                }
            };

            root.Child = null;

            Assert.Null(root.FindControl<Border>("foo"));
            Assert.Null(root.FindControl<Border>("bar"));
        }
        public void Controls_Should_Register_With_NameScope()
        {
            var root = new TestRoot
            {
                Child = new Border
                {
                    Name = "foo",
                    Child = new Border
                    {
                        Name = "bar",
                    }
                }
            };

            root.ApplyTemplate();

            Assert.Same(root.FindControl<Border>("foo"), root.Child);
            Assert.Same(root.FindControl<Border>("bar"), ((Border)root.Child).Child);
        }
Exemplo n.º 3
0
        public void Name_Can_Be_Set_While_Initializing()
        {
            using (AvaloniaLocator.EnterScope())
            {
                var root = new TestRoot();
                var child = new Border();

                ((ISupportInitialize)child).BeginInit();
                root.Child = child;
                child.Name = "foo";
                Assert.Null(root.FindControl<Border>("foo"));
                ((ISupportInitialize)child).EndInit();

                Assert.Same(root.FindControl<Border>("foo"), child);
            }
        }
Exemplo n.º 4
0
        public void Adding_To_Logical_Tree_Should_Register_With_NameScope()
        {
            using (AvaloniaLocator.EnterScope())
            {
                var root = new TestRoot();
                var child = new Border();

                child.Name = "foo";
                root.Child = child;

                Assert.Same(root.FindControl<Border>("foo"), child);
            }
        }