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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
19 additions and
1 deletions
-
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
-
tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs
|
|
|
@ -479,7 +479,7 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
if (IsInitialized) |
|
|
|
{ |
|
|
|
SyncTextAndValueProperties(false, null); |
|
|
|
SyncTextAndValueProperties(false, null, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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
|
|
|
|
|