From c301f8d922bb637df278f6afbadd5aa04d9ab0f3 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 9 Aug 2015 19:11:39 +0200 Subject: [PATCH] Make DropDown mouse selection work. --- Perspex.Controls/DropDown.cs | 9 ++++++++- Perspex.Controls/Primitives/Popup.cs | 10 ++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Perspex.Controls/DropDown.cs b/Perspex.Controls/DropDown.cs index 0d6e97e442..439a62c06d 100644 --- a/Perspex.Controls/DropDown.cs +++ b/Perspex.Controls/DropDown.cs @@ -7,11 +7,13 @@ namespace Perspex.Controls { using System; + using System.Linq; using Generators; using Perspex.Controls.Primitives; using Perspex.Controls.Templates; using Perspex.Input; using Perspex.Layout; + using VisualTree; public class DropDown : SelectingItemsControl, IContentControl { @@ -93,8 +95,13 @@ namespace Perspex.Controls { if (!this.IsDropDownOpen) { - this.IsDropDownOpen = true; + if (((IVisual)e.Source).GetVisualAncestors().Last().GetType() != typeof(PopupRoot)) + { + this.IsDropDownOpen = true; + } } + + base.OnPointerPressed(e); } protected override void OnTemplateApplied() diff --git a/Perspex.Controls/Primitives/Popup.cs b/Perspex.Controls/Primitives/Popup.cs index 3eabc40b83..99e737cacf 100644 --- a/Perspex.Controls/Primitives/Popup.cs +++ b/Perspex.Controls/Primitives/Popup.cs @@ -139,7 +139,8 @@ namespace Perspex.Controls.Primitives } /// - /// Gets or sets a value indicating whether the popup should stay open when the popup loses focus. + /// Gets or sets a value indicating whether the popup should stay open when the popup is + /// pressed or loses focus. /// public bool StaysOpen { @@ -316,13 +317,6 @@ namespace Perspex.Controls.Primitives { if (!this.StaysOpen) { - var routed = e as RoutedEventArgs; - - if (routed != null) - { - routed.Handled = true; - } - this.Close(); } }