Browse Source

Prevent controls appearing twice in logical tree.

portable-xaml
Steven Kirk 11 years ago
parent
commit
70a6b6dcb8
  1. 2
      src/Perspex.Controls/Mixins/ContentControlMixin.cs
  2. 18
      tests/Perspex.Controls.UnitTests/ContentControlTests.cs

2
src/Perspex.Controls/Mixins/ContentControlMixin.cs

@ -74,7 +74,7 @@ namespace Perspex.Controls.Mixins
UpdateLogicalChild(
sender,
logicalChildren,
null,
logicalChildren.FirstOrDefault(),
presenter.GetValue(ContentPresenter.ChildProperty));
subscriptions.Value.Add(sender, subscription);

18
tests/Perspex.Controls.UnitTests/ContentControlTests.cs

@ -98,6 +98,24 @@ namespace Perspex.Controls.UnitTests
Assert.Equal(new[] { child }, target.GetLogicalChildren());
}
[Fact]
public void Control_Content_Should_Be_Logical_Child_After_ApplyTemplate()
{
var target = new ContentControl
{
Template = GetTemplate(),
};
var child = new Control();
target.Content = child;
target.ApplyTemplate();
((ContentPresenter)target.Presenter).UpdateChild();
Assert.Equal(child.Parent, target);
Assert.Equal(child.GetLogicalParent(), target);
Assert.Equal(new[] { child }, target.GetLogicalChildren());
}
[Fact]
public void DataTemplate_Created_Control_Should_Be_Logical_Child_After_ApplyTemplate()
{

Loading…
Cancel
Save