Skip to content

NumericUpDown does not refresh shown text when changing NumberFormat #19107

@flucas1

Description

@flucas1

Describe the bug

When updating the NumberFormat in a binding, the text shown by the NumericUpDown does not change

To Reproduce

any binding

Expected behavior

to update the text automatically on binding change

Avalonia version

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs#L469

OS

No response

Additional context

I would update line 469 (OnNumberFormatChanged) and 565 (OnTextConverterChanged)

to match OnFormatStringChanged, and calling SyncTextAndValueProperties with the third parameter set to true;

This is the code I would consider right,

    protected virtual void OnNumberFormatChanged(NumberFormatInfo? oldValue, NumberFormatInfo? newValue)
    {
        if (IsInitialized)
        {
            SyncTextAndValueProperties(false, null, true);
        }
    }

    protected virtual void OnTextConverterChanged(IValueConverter? oldValue, IValueConverter? newValue)
    {
        if (IsInitialized)
        {
            SyncTextAndValueProperties(false, null, true);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions