public void Child_Control_Should_Appear_In_LogicalChildren() { var target = new Popup(); var child = new Control(); target.Child = child; Assert.Equal(new[] { child }, target.GetLogicalChildren()); }
public void Clearing_Child_Should_Remove_From_LogicalChildren() { var target = new Popup(); var child = new Control(); target.Child = child; target.Child = null; Assert.Equal(new ILogical[0], ((ILogical)target).LogicalChildren.ToList()); }
public void Setting_Child_Should_Set_Child_Controls_LogicalParent() { var target = new Popup(); var child = new Control(); target.Child = child; Assert.Equal(child.Parent, target); Assert.Equal(((ILogical)child).LogicalParent, target); }
public void Clearing_Child_Should_Clear_Child_Controls_Parent() { var target = new Popup(); var child = new Control(); target.Child = child; target.Child = null; Assert.Null(child.Parent); Assert.Null(((ILogical)child).LogicalParent); }
public void Setting_Child_Should_Fire_LogicalChildren_CollectionChanged() { var target = new Popup(); var child = new Control(); var called = false; ((ILogical)target).LogicalChildren.CollectionChanged += (s, e) => called = e.Action == NotifyCollectionChangedAction.Add; target.Child = child; Assert.True(called); }
public void PopupRoot_Should_Have_Template_Applied() { using (CreateServices()) { var target = new Popup(); var child = new Control(); target.Open(); Assert.Equal(1, target.PopupRoot.GetVisualChildren().Count()); var templatedChild = target.PopupRoot.GetVisualChildren().Single(); Assert.IsType<ContentPresenter>(templatedChild); Assert.Equal(target.PopupRoot, ((IControl)templatedChild).TemplatedParent); } }
public void PopupRoot_Should_Have_Popup_As_LogicalParent() { using (CreateServices()) { var target = new Popup(); target.Open(); Assert.Equal(target, target.PopupRoot.Parent); Assert.Equal(target, target.PopupRoot.GetLogicalParent()); } }
public void PopupRoot_Should_Be_Detached_From_Logical_Tree_When_Popup_Is_Detached() { using (CreateServices()) { var target = new Popup(); var root = new TestRoot { Child = target }; target.Open(); var popupRoot = (ILogical)target.PopupRoot; Assert.True(popupRoot.IsAttachedToLogicalTree); root.Child = null; Assert.False(((ILogical)target).IsAttachedToLogicalTree); } }
public void PopupRoot_Should_Initially_Be_Null() { using (CreateServices()) { var target = new Popup(); Assert.Null(target.PopupRoot); } }
public void PopupRoot_Should_Have_Null_VisualParent() { using (CreateServices()) { var target = new Popup(); target.Open(); Assert.Null(target.PopupRoot.GetVisualParent()); } }
public void Setting_Child_Should_Not_Set_Childs_VisualParent() { var target = new Popup(); var child = new Control(); target.Child = child; Assert.Null(((IVisual)child).VisualParent); }
public void Changing_Child_Should_Fire_LogicalChildren_CollectionChanged() { var target = new Popup(); var child1 = new Control(); var child2 = new Control(); var called = false; target.Child = child1; ((ILogical)target).LogicalChildren.CollectionChanged += (s, e) => called = true; target.Child = child2; Assert.True(called); }
/// <inheritdoc/> protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { if (_popup != null) { _popup.Opened -= PopupOpened; } _popup = e.NameScope.Get<Popup>("PART_Popup"); _popup.Opened += PopupOpened; }
private void InitializeComponent() { Application.LoadComponent(this, new Uri("/Test;component/MainWindow.xaml", UriKind.Relative)); this.textBox = (TextBox)this.FindName("textBox"); this.popup = (Popup)this.FindName("popup"); }
/// <inheritdoc/> protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { base.OnTemplateApplied(e); _popup = e.NameScope.Get<Popup>("PART_Popup"); _popup.DependencyResolver = DependencyResolver.Instance; _popup.Opened += PopupOpened; _popup.Closed += PopupClosed; }