From 6b7823d4ac9e377ee111bfb274aff7e813f5adc1 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Tue, 18 Oct 2011 15:20:18 +0000 Subject: [PATCH] CheckComboBox: dropdown closes when clicking outside the control. --- .../Implementation/CheckComboBox.cs | 18 +++++++++++++++++- .../CheckComboBox/Themes/Generic.xaml | 11 +++++++---- .../Core/Primitives/Selector.cs | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Implementation/CheckComboBox.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Implementation/CheckComboBox.cs index 212841fa..ca51b2c6 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Implementation/CheckComboBox.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Implementation/CheckComboBox.cs @@ -17,7 +17,7 @@ namespace Microsoft.Windows.Controls public CheckComboBox() { - + Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); } #endregion //Constructors @@ -66,6 +66,15 @@ namespace Microsoft.Windows.Controls #endregion //Base Class Overrides + #region Event Handlers + + private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e) + { + CloseDropDown(); + } + + #endregion //Event Handlers + #region Methods private void UpdateText() @@ -92,6 +101,13 @@ namespace Microsoft.Windows.Controls return item; } + private void CloseDropDown() + { + if (IsDropDownOpen) + IsDropDownOpen = false; + ReleaseMouseCapture(); + } + #endregion //Methods } } diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Themes/Generic.xaml index a3540ffa..df96be29 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CheckComboBox/Themes/Generic.xaml @@ -1,9 +1,12 @@  - + + + M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z @@ -12,7 +15,6 @@ - @@ -61,7 +63,7 @@ - + @@ -78,7 +80,8 @@ - + diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/Selector.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/Selector.cs index 5e12cfcc..18a37304 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/Selector.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/Selector.cs @@ -33,7 +33,7 @@ namespace Microsoft.Windows.Controls.Primitives #region Properties - public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(CheckListBox), new PropertyMetadata((ICommand)null)); + public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(Selector), new PropertyMetadata((ICommand)null)); [TypeConverter(typeof(CommandConverter))] public ICommand Command {