Browse Source

Apply NumericUpDown.FormatString changes immediately. (#16575)

* Prepare NumericUpDown.FormatString change unit test.

* Apply NumericUpDown.FormatString immediately on change.
pull/16593/head
pokorpa 2 years ago
committed by GitHub
parent
commit
d1ea3ff026
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
  2. 18
      tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs

2
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs

@ -479,7 +479,7 @@ namespace Avalonia.Controls
{
if (IsInitialized)
{
SyncTextAndValueProperties(false, null);
SyncTextAndValueProperties(false, null, true);
}
}

18
tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs

@ -62,6 +62,24 @@ namespace Avalonia.Controls.UnitTests
Assert.Equal(control.Value, expected);
}
[Fact]
public void FormatString_Is_Applied_Immediately()
{
RunTest((control, textbox) =>
{
const decimal value = 10.11m;
// Establish and verify initial conditions.
control.FormatString = "F0";
control.Value = value;
Assert.Equal(value.ToString("F0"), control.Text);
// Check that FormatString is applied.
control.FormatString = "F2";
Assert.Equal(value.ToString("F2"), control.Text);
});
}
public static IEnumerable<object[]> Increment_Decrement_TestData()
{
// if min and max are not defined and value was null, 0 should be ne new value after spin

Loading…
Cancel
Save