From f0a8f45362954f87e347f14be31a0226d1d0b8ec Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 12 Jan 2016 21:15:25 +0100 Subject: [PATCH] Removed hack from MenuItem. ItemsPresenterHost now makes ItemsControls within popups a supported scenario by default. --- src/Perspex.Controls/MenuItem.cs | 39 -------------------------------- 1 file changed, 39 deletions(-) diff --git a/src/Perspex.Controls/MenuItem.cs b/src/Perspex.Controls/MenuItem.cs index 1a95b48a41..560b93495f 100644 --- a/src/Perspex.Controls/MenuItem.cs +++ b/src/Perspex.Controls/MenuItem.cs @@ -2,18 +2,14 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Windows.Input; using Perspex.Controls.Mixins; -using Perspex.Controls.Presenters; using Perspex.Controls.Primitives; using Perspex.Controls.Templates; using Perspex.Input; using Perspex.Interactivity; using Perspex.Threading; -using Perspex.VisualTree; namespace Perspex.Controls { @@ -361,7 +357,6 @@ namespace Perspex.Controls _popup = e.NameScope.Get("PART_Popup"); _popup.DependencyResolver = DependencyResolver.Instance; - _popup.PopupRootCreated += PopupRootCreated; _popup.Opened += PopupOpened; _popup.Closed += PopupClosed; } @@ -416,40 +411,6 @@ namespace Perspex.Controls } } - /// - /// Called when the submenu's is created. - /// - /// The event sender. - /// The event args. - private void PopupRootCreated(object sender, EventArgs e) - { - var popup = (Popup)sender; - ItemsPresenter presenter = null; - - // Our ItemsPresenter is in a Popup which means that it's only created when the - // Popup is opened, therefore it wasn't found by ItemsControl.OnTemplateApplied. - // Now the Popup has been opened for the first time it should exist, so make sure - // the PopupRoot's template is applied and look for the ItemsPresenter. - foreach (var c in popup.PopupRoot.GetSelfAndVisualDescendents().OfType()) - { - if (c.Name == "itemsPresenter" && c is ItemsPresenter) - { - presenter = c as ItemsPresenter; - break; - } - - c.ApplyTemplate(); - } - - if (presenter != null) - { - // The presenter was found. Set its TemplatedParent so it thinks that it had a - // normal birth; may it never know its own perveristy. - presenter.TemplatedParent = this; - Presenter = presenter; - } - } - /// /// Called when the submenu's is opened. ///