public void Replacing_Template_Releases_Events() { var p1 = new ContentPresenter { Name = "Content_1_Presenter" }; var p2 = new ContentPresenter { Name = "Content_2_Presenter" }; var target = new TestControl { Template = new FuncControlTemplate(_ => new Panel { Children = { p1, p2 } }) }; target.ApplyTemplate(); Control tc; p1.Content = tc = new Control(); p1.UpdateChild(); Assert.Contains(tc, target.GetLogicalChildren()); p2.Content = tc = new Control(); p2.UpdateChild(); Assert.Contains(tc, target.GetLogicalChildren()); target.Template = null; p1.Content = tc = new Control(); p1.UpdateChild(); Assert.DoesNotContain(tc, target.GetLogicalChildren()); p2.Content = tc = new Control(); p2.UpdateChild(); Assert.DoesNotContain(tc, target.GetLogicalChildren()); }
public void Multiple_Mixin_Usages_Should_Not_Throw() { var target = new TestControl() { Template = new FuncControlTemplate(_ => new Panel { Children = { new ContentPresenter { Name = "Content_1_Presenter" }, new ContentPresenter { Name = "Content_2_Presenter" } } }) }; var ex = Record.Exception(() => target.ApplyTemplate()); Assert.Null(ex); }