diff --git a/Directory.packages.props b/Directory.packages.props
index 10ca8313042..a9bdb53627f 100644
--- a/Directory.packages.props
+++ b/Directory.packages.props
@@ -26,9 +26,9 @@
-
+
-
\ No newline at end of file
+
diff --git a/src/MaterialDesignThemes.Wpf/DecimalUpDown.cs b/src/MaterialDesignThemes.Wpf/DecimalUpDown.cs
index 99ddbaa1570..01d2cf035a2 100644
--- a/src/MaterialDesignThemes.Wpf/DecimalUpDown.cs
+++ b/src/MaterialDesignThemes.Wpf/DecimalUpDown.cs
@@ -6,9 +6,9 @@ namespace MaterialDesignThemes.Wpf;
public class DecimalUpDown
#if NET8_0_OR_GREATER
- : UpDownBase2
+ : UpDownBase
#else
- : UpDownBase2
+ : UpDownBase
#endif
{
static DecimalUpDown()
diff --git a/src/MaterialDesignThemes.Wpf/NumericUpDown.cs b/src/MaterialDesignThemes.Wpf/NumericUpDown.cs
index 26bddd32bdb..e5e310a9b07 100644
--- a/src/MaterialDesignThemes.Wpf/NumericUpDown.cs
+++ b/src/MaterialDesignThemes.Wpf/NumericUpDown.cs
@@ -6,9 +6,9 @@ namespace MaterialDesignThemes.Wpf;
public class NumericUpDown
#if NET8_0_OR_GREATER
- : UpDownBase2
+ : UpDownBase
#else
- : UpDownBase2
+ : UpDownBase
#endif
{
static NumericUpDown()
diff --git a/src/MaterialDesignThemes.Wpf/UpDownBase.cs b/src/MaterialDesignThemes.Wpf/UpDownBase.cs
index 64e4834d8a7..a99a7ccb2c9 100644
--- a/src/MaterialDesignThemes.Wpf/UpDownBase.cs
+++ b/src/MaterialDesignThemes.Wpf/UpDownBase.cs
@@ -5,14 +5,13 @@ namespace MaterialDesignThemes.Wpf;
#if NET8_0_OR_GREATER
-
using System.Numerics;
-public class UpDownBase2 : UpDownBase
+public class UpDownBase : UpDownBase
where T : INumber, IMinMaxValue
{
- private static readonly Type SelfType = typeof(UpDownBase2);
+ private static readonly Type SelfType = typeof(UpDownBase);
- private static UpDownBase2 ToUpDownBase(DependencyObject dependencyObject) => (UpDownBase2)dependencyObject;
+ private static UpDownBase ToUpDownBase(DependencyObject dependencyObject) => (UpDownBase)dependencyObject;
private static T MinValue => T.MinValue;
private static T MaxValue => T.MaxValue;
@@ -25,13 +24,13 @@ private static bool TryParse(string text, IFormatProvider? formatProvider, out T
=> T.TryParse(text, formatProvider, out value);
private static int Compare(T value1, T value2) => value1.CompareTo(value2);
#else
-public class UpDownBase2 : UpDownBase
+public class UpDownBase : UpDownBase
where TArithmetic : IArithmetic, new()
{
- private static readonly Type SelfType = typeof(UpDownBase2);
+ private static readonly Type SelfType = typeof(UpDownBase);
private static readonly TArithmetic _arithmetic = new();
- private static UpDownBase2 ToUpDownBase(DependencyObject dependencyObject) => (UpDownBase2)dependencyObject;
+ private static UpDownBase ToUpDownBase(DependencyObject dependencyObject) => (UpDownBase)dependencyObject;
private static T MinValue => _arithmetic.MinValue();
private static T MaxValue => _arithmetic.MaxValue();
@@ -43,7 +42,6 @@ public class UpDownBase2 : UpDownBase
private static bool TryParse(string text, IFormatProvider? formatProvider, out T? value)
=> _arithmetic.TryParse(text, formatProvider, out value);
private static int Compare(T value1, T value2) => _arithmetic.Compare(value1, value2);
-
#endif
#region DependencyProperties
diff --git a/tests/MaterialDesignThemes.UITests/TestBase.cs b/tests/MaterialDesignThemes.UITests/TestBase.cs
index 25d3b12af31..66615f971c1 100644
--- a/tests/MaterialDesignThemes.UITests/TestBase.cs
+++ b/tests/MaterialDesignThemes.UITests/TestBase.cs
@@ -4,7 +4,7 @@
[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: GenerateHelpers(typeof(AutoSuggestBox))]
[assembly: GenerateHelpers(typeof(ColorPicker))]
-//[assembly: GenerateHelpers(typeof(DecimalUpDown))]
+[assembly: GenerateHelpers(typeof(DecimalUpDown))]
[assembly: GenerateHelpers(typeof(DialogHost))]
[assembly: GenerateHelpers(typeof(DrawerHost))]
[assembly: GenerateHelpers(typeof(NumericUpDown))]
diff --git a/tests/MaterialDesignThemes.UITests/WPF/UpDownControls/DecimalUpDownTests.cs b/tests/MaterialDesignThemes.UITests/WPF/UpDownControls/DecimalUpDownTests.cs
new file mode 100644
index 00000000000..d4cad60086b
--- /dev/null
+++ b/tests/MaterialDesignThemes.UITests/WPF/UpDownControls/DecimalUpDownTests.cs
@@ -0,0 +1,118 @@
+namespace MaterialDesignThemes.UITests.WPF.UpDownControls;
+
+public class DecimalUpDownTests(ITestOutputHelper output) : TestBase(output)
+{
+ [Fact]
+ public async Task NumericButtons_IncreaseAndDecreaseValue()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ var numericUpDown = await LoadXaml("""
+
+ """);
+ var plusButton = await numericUpDown.GetElement("PART_IncreaseButton");
+ var minusButton = await numericUpDown.GetElement("PART_DecreaseButton");
+ var textBox = await numericUpDown.GetElement("PART_TextBox");
+
+ Assert.Equal("1", await textBox.GetText());
+ Assert.Equal(1, await numericUpDown.GetValue());
+
+ await plusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("2", await textBox.GetText());
+ Assert.Equal(2, await numericUpDown.GetValue());
+ });
+
+ await minusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("1", await textBox.GetText());
+ Assert.Equal(1, await numericUpDown.GetValue());
+ });
+ }
+
+ [Fact]
+ public async Task NumericButtons_WithMaximum_DisablesPlusButton()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ var numericUpDown = await LoadXaml("""
+
+ """);
+ var plusButton = await numericUpDown.GetElement("PART_IncreaseButton");
+ var minusButton = await numericUpDown.GetElement("PART_DecreaseButton");
+ var textBox = await numericUpDown.GetElement("PART_TextBox");
+
+ await plusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("2", await textBox.GetText());
+ Assert.Equal(2, await numericUpDown.GetValue());
+ });
+
+ Assert.False(await plusButton.GetIsEnabled());
+
+ await minusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("1", await textBox.GetText());
+ Assert.Equal(1, await numericUpDown.GetValue());
+ });
+
+ Assert.True(await plusButton.GetIsEnabled());
+ }
+
+ [Fact]
+ public async Task NumericButtons_WithMinimum_DisablesMinusButton()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ var numericUpDown = await LoadXaml("""
+
+ """);
+ var plusButton = await numericUpDown.GetElement("PART_IncreaseButton");
+ var minusButton = await numericUpDown.GetElement("PART_DecreaseButton");
+ var textBox = await numericUpDown.GetElement("PART_TextBox");
+
+ await minusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("1", await textBox.GetText());
+ Assert.Equal(1, await numericUpDown.GetValue());
+ });
+
+ Assert.False(await minusButton.GetIsEnabled());
+
+ await plusButton.LeftClick();
+ await Wait.For(async () =>
+ {
+ Assert.Equal("2", await textBox.GetText());
+ Assert.Equal(2, await numericUpDown.GetValue());
+ });
+
+ Assert.True(await minusButton.GetIsEnabled());
+ }
+
+ [Fact]
+ public async Task MaxAndMinAssignments_CoerceValueToBeInRange()
+ {
+ await using var recorder = new TestRecorder(App);
+
+ var numericUpDown = await LoadXaml("""
+
+ """);
+
+ await numericUpDown.SetMaximum(1);
+ Assert.Equal(1, await numericUpDown.GetValue());
+
+ await numericUpDown.SetMinimum(3);
+ Assert.Equal(3, await numericUpDown.GetValue());
+ Assert.Equal(3, await numericUpDown.GetMaximum());
+
+ await numericUpDown.SetMaximum(2);
+ Assert.Equal(3, await numericUpDown.GetValue());
+ Assert.Equal(3, await numericUpDown.GetMinimum());
+ Assert.Equal(3, await numericUpDown.GetMaximum());
+ }
+}
diff --git a/tests/MaterialDesignThemes.UITests/WPF/NumericUpDowns/NumericUpDownTests.cs b/tests/MaterialDesignThemes.UITests/WPF/UpDownControls/NumericUpDownTests.cs
similarity index 98%
rename from tests/MaterialDesignThemes.UITests/WPF/NumericUpDowns/NumericUpDownTests.cs
rename to tests/MaterialDesignThemes.UITests/WPF/UpDownControls/NumericUpDownTests.cs
index 13788012594..1f722218042 100644
--- a/tests/MaterialDesignThemes.UITests/WPF/NumericUpDowns/NumericUpDownTests.cs
+++ b/tests/MaterialDesignThemes.UITests/WPF/UpDownControls/NumericUpDownTests.cs
@@ -1,4 +1,5 @@
-namespace MaterialDesignThemes.UITests.WPF.NumericUpDowns;
+namespace MaterialDesignThemes.UITests.WPF.UpDownControls;
+
public class NumericUpDownTests(ITestOutputHelper output) : TestBase(output)
{