diff --git a/HandyControl/Controls/Input/DatePicker.cs b/HandyControl/Controls/Input/DatePicker.cs
new file mode 100644
index 00000000..993541ec
--- /dev/null
+++ b/HandyControl/Controls/Input/DatePicker.cs
@@ -0,0 +1,113 @@
+using System;
+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 = ElementTextBox, Type = typeof(DatePickerTextBox))]
+ public class DatePicker : System.Windows.Controls.DatePicker, IDataInput
+ {
+ private const string ElementTextBox = "PART_TextBox";
+
+ private System.Windows.Controls.TextBox _textBox;
+
+ public DatePicker()
+ {
+ CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) =>
+ {
+ ClearValue(SelectedDateProperty);
+ ClearValue(TextProperty);
+ }));
+ }
+
+ public override void OnApplyTemplate()
+ {
+ if (_textBox != null)
+ {
+ _textBox.TextChanged -= TextBox_TextChanged;
+ }
+
+ base.OnApplyTemplate();
+
+ _textBox = GetTemplateChild(ElementTextBox) as System.Windows.Controls.TextBox;
+ if (_textBox != null)
+ {
+ _textBox.TextChanged += TextBox_TextChanged;
+ }
+ }
+
+ private void TextBox_TextChanged(object sender, TextChangedEventArgs e) => VerifyData();
+
+ public Func> VerifyFunc { get; set; }
+
+ public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
+ "IsError", typeof(bool), typeof(DatePicker), new PropertyMetadata(ValueBoxes.FalseBox));
+
+ public bool IsError
+ {
+ get => (bool) GetValue(IsErrorProperty);
+ set => SetValue(IsErrorProperty, value);
+ }
+
+ public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
+ "ErrorStr", typeof(string), typeof(DatePicker), 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(DatePicker), 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(DatePicker), new PropertyMetadata(ValueBoxes.FalseBox));
+
+ public bool ShowClearButton
+ {
+ get => (bool) GetValue(ShowClearButtonProperty);
+ set => SetValue(ShowClearButtonProperty, value);
+ }
+
+ public virtual bool VerifyData()
+ {
+ OperationResult result;
+
+ if (VerifyFunc != null)
+ {
+ result = VerifyFunc.Invoke(Text);
+ }
+ else
+ {
+ if (!string.IsNullOrEmpty(Text))
+ {
+ 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/HandyControl/Controls/Input/PasswordBox.cs b/HandyControl/Controls/Input/PasswordBox.cs
index 22e2168f..392fda2e 100644
--- a/HandyControl/Controls/Input/PasswordBox.cs
+++ b/HandyControl/Controls/Input/PasswordBox.cs
@@ -11,6 +11,7 @@ using HandyControl.Properties.Langs;
namespace HandyControl.Controls
{
///
+ [TemplatePart(Name = ElementPasswordBox, Type = typeof(System.Windows.Controls.PasswordBox))]
public class PasswordBox : Control, IDataInput
{
private const string ElementPasswordBox = "PART_PasswordBox";
diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj
index 52f78b16..11a33412 100644
--- a/HandyControl/HandyControl.csproj
+++ b/HandyControl/HandyControl.csproj
@@ -53,6 +53,7 @@
+
diff --git a/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
index fd89b9ec..ac64b1b1 100644
--- a/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/ComboBoxBaseStyle.xaml
@@ -29,6 +29,9 @@
+
+
+
@@ -45,17 +48,21 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -109,6 +116,9 @@
+
+
+
@@ -167,6 +177,10 @@
+
+
+
+
@@ -222,6 +236,10 @@
+
+
+
+
@@ -300,6 +318,9 @@
+
+
+
@@ -331,7 +352,7 @@
-
+
@@ -368,6 +389,11 @@
+
+
+
+
+
@@ -396,7 +422,7 @@
-
+
@@ -433,6 +459,11 @@
+
+
+
+
+
@@ -495,9 +526,6 @@
-
-
-
@@ -627,6 +655,10 @@
+
+
+
+
@@ -722,6 +754,10 @@
+
+
+
+
@@ -762,7 +798,7 @@
-
+
@@ -844,6 +880,11 @@
+
+
+
+
+
@@ -881,7 +922,7 @@
-
+
@@ -963,6 +1004,11 @@
+
+
+
+
+
diff --git a/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml b/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
index d36a7acc..125bc1ae 100644
--- a/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/DatePickerBaseStyle.xaml
@@ -1,6 +1,8 @@
+ xmlns:controls="clr-namespace:HandyControl.Controls"
+ xmlns:system="clr-namespace:System;assembly=mscorlib"
+ xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
@@ -80,4 +82,279 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml b/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
index e57c6a43..e3cfbc3c 100644
--- a/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
@@ -1,7 +1,8 @@
+ xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
+ xmlns:system="clr-namespace:System;assembly=mscorlib">
@@ -57,4 +58,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
index d4148471..865a5575 100644
--- a/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/PasswordBoxBaseStyle.xaml
@@ -68,7 +68,9 @@
-
+
+
+
@@ -98,7 +100,9 @@
-
+
+
+
diff --git a/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml b/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
index a7cf49e3..f801dc4f 100644
--- a/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
+++ b/HandyControl/Themes/Styles/Base/TextBoxBaseStyle.xaml
@@ -80,12 +80,14 @@
-
+
+
+
@@ -107,12 +109,14 @@
-
+
+
+
diff --git a/HandyControl/Themes/Styles/DatePicker.xaml b/HandyControl/Themes/Styles/DatePicker.xaml
index a62bd2a5..cb79d940 100644
--- a/HandyControl/Themes/Styles/DatePicker.xaml
+++ b/HandyControl/Themes/Styles/DatePicker.xaml
@@ -1,7 +1,6 @@
+ xmlns:controls="clr-namespace:HandyControl.Controls">
@@ -9,117 +8,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/HandyControl/Themes/Styles/NumericUpDown.xaml b/HandyControl/Themes/Styles/NumericUpDown.xaml
index 65294048..58ca728d 100644
--- a/HandyControl/Themes/Styles/NumericUpDown.xaml
+++ b/HandyControl/Themes/Styles/NumericUpDown.xaml
@@ -1,8 +1,6 @@
+ xmlns:controls="clr-namespace:HandyControl.Controls">
@@ -10,221 +8,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/HandyControlDemo/Data/MessageToken.cs b/HandyControlDemo/Data/MessageToken.cs
index bdce5727..f2ecae60 100644
--- a/HandyControlDemo/Data/MessageToken.cs
+++ b/HandyControlDemo/Data/MessageToken.cs
@@ -44,6 +44,8 @@
public static readonly string PasswordBoxDemoCtl = nameof(PasswordBoxDemoCtl);
+ public static readonly string DatePickerDemoCtl = nameof(DatePickerDemoCtl);
+
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
@@ -56,7 +58,7 @@
public static readonly string CalendarDemoCtl = nameof(CalendarDemoCtl);
- public static readonly string DatePickerDemoCtl = nameof(DatePickerDemoCtl);
+ public static readonly string NaiveDatePickerDemoCtl = nameof(NaiveDatePickerDemoCtl);
public static readonly string NaiveTextBoxDemoCtl = nameof(NaiveTextBoxDemoCtl);
diff --git a/HandyControlDemo/Data/MessageToken.tt b/HandyControlDemo/Data/MessageToken.tt
index ec9d74e2..7fca17ce 100644
--- a/HandyControlDemo/Data/MessageToken.tt
+++ b/HandyControlDemo/Data/MessageToken.tt
@@ -24,7 +24,8 @@ var controlList = new List
"CircleProgressBarDemoCtl",
"TextBoxDemoCtl",
"ComboBoxDemoCtl",
- "PasswordBoxDemoCtl"
+ "PasswordBoxDemoCtl",
+ "DatePickerDemoCtl"
};
var styleList = new List
{
@@ -34,7 +35,7 @@ var styleList = new List
"ProgressBarDemoCtl",
"TabControlDemoCtl",
"CalendarDemoCtl",
- "DatePickerDemoCtl",
+ "NaiveDatePickerDemoCtl",
"NaiveTextBoxDemoCtl",
"TextBlockDemoCtl",
"NaiveComboBoxDemoCtl",
diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj
index 3ea8bca5..86388ef9 100644
--- a/HandyControlDemo/HandyControlDemo.csproj
+++ b/HandyControlDemo/HandyControlDemo.csproj
@@ -120,6 +120,9 @@
CompareSliderDemoCtl.xaml
+
+ DatePickerDemoCtl.xaml
+
GrowlDemoCtl.xaml
@@ -180,8 +183,8 @@
DataGridDemoCtl.xaml
-
- DatePickerDemoCtl.xaml
+
+ NaiveDatePickerDemoCtl.xaml
ExpanderDemoCtl.xaml
@@ -344,6 +347,10 @@
Designer
MSBuild:Compile
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
@@ -424,7 +431,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
diff --git a/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml
index 34e29207..840081e3 100644
--- a/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml
+++ b/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml
@@ -2,8 +2,20 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
+ xmlns:system="clr-namespace:System;assembly=mscorlib"
+ xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="White">
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml.cs
index 733dfe24..a7f7a755 100644
--- a/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml.cs
+++ b/HandyControlDemo/UserControl/Controls/DatePickerDemoCtl.xaml.cs
@@ -1,9 +1,5 @@
-// ReSharper disable once CheckNamespace
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl
{
- ///
- /// DatePickerDemoCtl.xaml 的交互逻辑
- ///
public partial class DatePickerDemoCtl
{
public DatePickerDemoCtl()
diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
index c550f4af..ae71a652 100644
--- a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
+++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml
@@ -85,7 +85,7 @@
-
+
@@ -134,16 +134,21 @@
-
+
-
+
+
+
+
+
+
@@ -179,7 +184,7 @@
-
+
diff --git a/HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml.cs
deleted file mode 100644
index 733dfe24..00000000
--- a/HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// ReSharper disable once CheckNamespace
-namespace HandyControlDemo.UserControl
-{
- ///
- /// DatePickerDemoCtl.xaml 的交互逻辑
- ///
- public partial class DatePickerDemoCtl
- {
- public DatePickerDemoCtl()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml b/HandyControlDemo/UserControl/Styles/NaiveDatePickerDemoCtl.xaml
similarity index 96%
rename from HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml
rename to HandyControlDemo/UserControl/Styles/NaiveDatePickerDemoCtl.xaml
index d3207e3d..0c241c84 100644
--- a/HandyControlDemo/UserControl/Styles/DatePickerDemoCtl.xaml
+++ b/HandyControlDemo/UserControl/Styles/NaiveDatePickerDemoCtl.xaml
@@ -1,4 +1,4 @@
-