public void Nested_Templated_Control_Should_Not_Have_Template_Applied() { var target = new TemplatedControl { Template = new FuncControlTemplate(_ => new ScrollViewer()) }; target.ApplyTemplate(); var child = (ScrollViewer)target.GetVisualChildren().Single(); Assert.Empty(child.GetVisualChildren()); }
public void Templated_Child_Should_Be_NameScope() { var target = new TemplatedControl { Template = new FuncControlTemplate(_ => new Decorator { Child = new Panel { Children = new Controls { new TextBlock(), new Border(), } } }), }; target.ApplyTemplate(); Assert.NotNull(NameScope.GetNameScope((Control)target.GetVisualChildren().Single())); }
public void Templated_Child_Should_Have_Parent_Set() { var target = new TemplatedControl { Template = new FuncControlTemplate(_ => new Decorator()) }; target.ApplyTemplate(); var child = (Decorator)target.GetVisualChildren().Single(); Assert.Equal(target, child.Parent); Assert.Equal(target, child.GetLogicalParent()); }