From a06e3ffd73bda863d3f53ffa55c01037fb066890 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 9 Apr 2016 16:01:11 +0200 Subject: [PATCH] Fix ContentControlMixin. Correctly track the current ContentControl child. Fixes a bug in MenuItem where the first child MenuItem was not a logical child after the template got applied. --- src/Perspex.Controls/Mixins/ContentControlMixin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Perspex.Controls/Mixins/ContentControlMixin.cs b/src/Perspex.Controls/Mixins/ContentControlMixin.cs index a381c7c773..a29b471241 100644 --- a/src/Perspex.Controls/Mixins/ContentControlMixin.cs +++ b/src/Perspex.Controls/Mixins/ContentControlMixin.cs @@ -74,7 +74,7 @@ namespace Perspex.Controls.Mixins UpdateLogicalChild( sender, logicalChildren, - logicalChildren.FirstOrDefault(), + null, presenter.GetValue(ContentPresenter.ChildProperty)); subscriptions.Value.Add(sender, subscription); @@ -143,7 +143,7 @@ namespace Perspex.Controls.Mixins child = newValue as IControl; - if (child != null) + if (child != null && !logicalChildren.Contains(child)) { child.SetValue(Control.TemplatedParentProperty, control.TemplatedParent); logicalChildren.Add(child);