diff --git a/README-cn.md b/README-cn.md
index f857f2eb..f6f1fe21 100644
--- a/README-cn.md
+++ b/README-cn.md
@@ -119,6 +119,10 @@ Step 4: Enjoy coding
## Latest examples
+### CheckComboBox
+
+![CheckComboBox](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/CheckComboBox.png)
+
### ImageSelector
![ImageSelector](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/ImageSelector.png)
@@ -135,12 +139,12 @@ Step 4: Enjoy coding
![GooeyEffect](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/GooeyEffect.gif)
+## History publication
+
### GlowWindow
![GlowWindow](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/GlowWindow.png)
-## History publication
-
### FlowDocumentScrollViewerStyle
![FlowDocumentScrollViewerStyle](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/FlowDocumentScrollViewer.png)
diff --git a/README.md b/README.md
index 8625625f..c5bb1625 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,10 @@ Step 4: Enjoy coding
## Latest examples
+### CheckComboBox
+
+![CheckComboBox](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/CheckComboBox.png)
+
### ImageSelector
![ImageSelector](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/ImageSelector.png)
@@ -135,12 +139,12 @@ Step 4: Enjoy coding
![GooeyEffect](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/GooeyEffect.gif)
+## History publication
+
### GlowWindow
![GlowWindow](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/GlowWindow.png)
-## History publication
-
### FlowDocumentScrollViewerStyle
![FlowDocumentScrollViewerStyle](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/FlowDocumentScrollViewer.png)
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
index 6487bf79..4a10a841 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
@@ -1,14 +1,33 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
index 66837b23..cbbe9643 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
@@ -17,9 +17,7 @@
-
-
-
+
diff --git a/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs b/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs
index f7a87396..edd3f495 100644
--- a/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Input/CheckComboBox/CheckComboBox.cs
@@ -1,13 +1,16 @@
-using System.Windows;
+using System;
+using System.ComponentModel;
+using System.Windows;
using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
+using System.Windows.Input;
using HandyControl.Data;
+using HandyControl.Interactivity;
namespace HandyControl.Controls
{
[TemplatePart(Name = ElementPanel, Type = typeof(Panel))]
[TemplatePart(Name = ElementSelectAll, Type = typeof(CheckComboBoxItem))]
- public class CheckComboBox : ListBox
+ public class CheckComboBox : ListBox, IDataInput
{
private const string ElementPanel = "PART_Panel";
@@ -15,12 +18,58 @@ namespace HandyControl.Controls
private Panel _panel;
- private Popup _popup;
-
private CheckComboBoxItem _selectAllItem;
private bool _isInternalAction;
+ public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
+ "IsError", typeof(bool), typeof(CheckComboBox), new PropertyMetadata(ValueBoxes.FalseBox));
+
+ public bool IsError
+ {
+ get => (bool) GetValue(IsErrorProperty);
+ set => SetValue(IsErrorProperty, ValueBoxes.BooleanBox(value));
+ }
+
+ public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
+ "ErrorStr", typeof(string), typeof(CheckComboBox), new PropertyMetadata(default(string)));
+
+ public string ErrorStr
+ {
+ get => (string) GetValue(ErrorStrProperty);
+ set => SetValue(ErrorStrProperty, value);
+ }
+
+ public static readonly DependencyProperty TextTypeProperty = DependencyProperty.Register(
+ "TextType", typeof(TextType), typeof(CheckComboBox), new PropertyMetadata(default(TextType)));
+
+ public TextType TextType
+ {
+ get => (TextType) GetValue(TextTypeProperty);
+ set => SetValue(TextTypeProperty, value);
+ }
+
+ public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
+ "ShowClearButton", typeof(bool), typeof(CheckComboBox), new PropertyMetadata(ValueBoxes.FalseBox));
+
+ public bool ShowClearButton
+ {
+ get => (bool) GetValue(ShowClearButtonProperty);
+ set => SetValue(ShowClearButtonProperty, ValueBoxes.BooleanBox(value));
+ }
+
+ public static readonly DependencyProperty MaxDropDownHeightProperty =
+ System.Windows.Controls.ComboBox.MaxDropDownHeightProperty.AddOwner(typeof(CheckComboBox),
+ new FrameworkPropertyMetadata(SystemParameters.PrimaryScreenHeight / 3));
+
+ [Bindable(true), Category("Layout")]
+ [TypeConverter(typeof(LengthConverter))]
+ public double MaxDropDownHeight
+ {
+ get => (double) GetValue(MaxDropDownHeightProperty);
+ set => SetValue(MaxDropDownHeightProperty, value);
+ }
+
public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register(
"IsDropDownOpen", typeof(bool), typeof(CheckComboBox), new PropertyMetadata(ValueBoxes.FalseBox));
@@ -48,7 +97,11 @@ namespace HandyControl.Controls
set => SetValue(ShowSelectAllButtonProperty, ValueBoxes.BooleanBox(value));
}
- public CheckComboBox() => AddHandler(Controls.Tag.ClosedEvent, new RoutedEventHandler(Tags_OnClosed));
+ public CheckComboBox()
+ {
+ AddHandler(Controls.Tag.ClosedEvent, new RoutedEventHandler(Tags_OnClosed));
+ CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => SelectedItems.Clear()));
+ }
private void Tags_OnClosed(object sender, RoutedEventArgs e)
{
@@ -77,14 +130,48 @@ namespace HandyControl.Controls
}
}
+ public bool VerifyData()
+ {
+ OperationResult result;
+
+ if (VerifyFunc != null)
+ {
+ result = VerifyFunc.Invoke(null);
+ }
+ else
+ {
+ if (SelectedItems.Count > 0)
+ {
+ result = OperationResult.Success();
+ }
+ else if (InfoElement.GetNecessary(this))
+ {
+ result = OperationResult.Failed(Properties.Langs.Lang.IsNecessary);
+ }
+ else
+ {
+ result = OperationResult.Success();
+ }
+ }
+
+ IsError = !result.Data;
+ ErrorStr = result.Message;
+ return result.Data;
+ }
+
+ public Func> VerifyFunc { get; set; }
+
private void SwitchAllItems(bool selected)
{
if (_isInternalAction) return;
_isInternalAction = true;
- foreach (CheckComboBoxItem item in ItemContainerGenerator.Items)
+ foreach (var item in ItemContainerGenerator.Items)
{
- item.SetCurrentValue(ListBoxItem.IsSelectedProperty, selected);
+ if (ItemContainerGenerator.ContainerFromItem(item) is CheckComboBoxItem checkComboBoxItem)
+ {
+ checkComboBoxItem.SetCurrentValue(ListBoxItem.IsSelectedProperty, selected);
+ }
}
_isInternalAction = false;
@@ -98,12 +185,18 @@ namespace HandyControl.Controls
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
UpdateTags();
+ VerifyData();
+
base.OnSelectionChanged(e);
}
+ protected override bool IsItemItsOwnContainerOverride(object item) => item is CheckComboBoxItem;
+
+ protected override DependencyObject GetContainerForItemOverride() => new CheckComboBoxItem();
+
private void UpdateTags()
{
- if (_isInternalAction) return;
+ if (_panel == null || _isInternalAction) return;
if (_selectAllItem != null)
{
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index edf474c4..00b8950f 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -118,6 +118,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.Designer.cs
index dc9c63af..06b51481 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.Designer.cs
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.Designer.cs
@@ -59,7 +59,18 @@ namespace HandyControl.Properties.Langs {
resourceCulture = value;
}
}
-
+
+ ///
+ /// 查找类似 所有 的本地化字符串。
+ ///
+ public static string All
+ {
+ get
+ {
+ return ResourceManager.GetString("All", resourceCulture);
+ }
+ }
+
///
/// 查找类似 上午 的本地化字符串。
///
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.en.resx
index d9294600..b12aa4f1 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.en.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.en.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fa.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fa.resx
index 5d89a3fb..aa869a08 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fa.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fa.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fr.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fr.resx
index 3244677f..14180e25 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fr.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.fr.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ko-KR.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ko-KR.resx
index 2b5b057b..74be0fba 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ko-KR.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ko-KR.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.pt-BR.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.pt-BR.resx
index 9e82b831..724099b7 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.pt-BR.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.pt-BR.resx
@@ -237,4 +237,7 @@
Geral
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.resx
index 7d98ff34..5b9d9f8d 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.resx
@@ -237,4 +237,7 @@
杂项
+
+ 全部
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ru.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ru.resx
index 4b8c4285..35b6367a 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ru.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.ru.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.tr.resx b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.tr.resx
index 1ee2f1af..ea40fa6f 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/Lang.tr.resx
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/Lang.tr.resx
@@ -237,4 +237,7 @@
Miscellaneous
+
+ All
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.cs b/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.cs
index 9f52f043..5302237c 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.cs
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.cs
@@ -37,7 +37,8 @@ namespace HandyControl.Properties.Langs
private void UpdateLangs()
{
- OnPropertyChanged(nameof(Am));
+ OnPropertyChanged(nameof(All));
+ OnPropertyChanged(nameof(Am));
OnPropertyChanged(nameof(Cancel));
OnPropertyChanged(nameof(CannotRegisterCompositeCommandInItself));
OnPropertyChanged(nameof(CannotRegisterSameCommandTwice));
@@ -78,6 +79,11 @@ namespace HandyControl.Properties.Langs
OnPropertyChanged(nameof(ZoomOut));
}
+ ///
+ /// 查找类似 所有 的本地化字符串。
+ ///
+ public string All => Lang.All;
+
///
/// 查找类似 上午 的本地化字符串。
///
@@ -282,6 +288,11 @@ namespace HandyControl.Properties.Langs
public class LangKeys
{
+ ///
+ /// 查找类似 所有 的本地化字符串。
+ ///
+ public static string All = nameof(All);
+
///
/// 查找类似 上午 的本地化字符串。
///
diff --git a/src/Shared/HandyControl_Shared/Themes/Basic/Converters.xaml b/src/Shared/HandyControl_Shared/Themes/Basic/Converters.xaml
index 97245b65..97863a55 100644
--- a/src/Shared/HandyControl_Shared/Themes/Basic/Converters.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Basic/Converters.xaml
@@ -18,6 +18,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
index e60f945c..0206170a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
@@ -1,19 +1,44 @@
+ xmlns:ex="clr-namespace:HandyControl.Tools.Extension"
+ xmlns:themes="clr-namespace:HandyControl.Themes"
+ xmlns:system="clr-namespace:System;assembly=System.Runtime"
+ xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
+ xmlns:langs="clr-namespace:HandyControl.Properties.Langs">
-
-
+
+
-
-
+
-
+
-
+
-
+
@@ -118,8 +173,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
@@ -141,8 +210,412 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/CheckComboBox.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/CheckComboBox.xaml
index 8656e2fc..0278e91e 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/CheckComboBox.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/CheckComboBox.xaml
@@ -1,4 +1,5 @@
@@ -8,4 +9,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs
new file mode 100644
index 00000000..e5b3e39a
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace HandyControl.Tools.Converter
+{
+ public class Object2VisibilityReConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value == null ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}