-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding validation error is not updated properly #16937
Comments
The same happens when I use a converter. For example, if I enter a number and backspace it then there are no errors. If I enter some invalid input and backspace it then the validation error is not reset. Also with the converter this happened in older versions too (tested in 11.0.13), but not always. using Avalonia.Data;
using Avalonia.Data.Converters;
using System;
using System.Globalization;
namespace TestAvaloniaConverter.Converters
{
internal class SomeConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
=> value?.ToString();
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is null)
{
return null;
}
if (value is string str)
{
if (string.IsNullOrWhiteSpace(str))
{
return null;
}
if (int.TryParse(str, out var res))
{
return res;
}
return new BindingNotification(new Exception("not int"), BindingErrorType.DataValidationError);
}
return new BindingNotification(new Exception("not string"), BindingErrorType.DataValidationError);
}
}
} xmlns:conv="using:TestAvaloniaConverter.Converters"
...
<Window.Resources>
<conv:SomeConverter x:Key="SomeConverter" />
</Window.Resources>
<TextBox Width="300" Text="{Binding Number, Converter={StaticResource SomeConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center"/> |
Also using |
I got the same problem. Is there any way to solve this problem? |
@Hzlin7, as far as I can remember, for now I'm stuck with using binding to a |
@maxkatz6, could you, please, add proper labels to the issue? I am sorry to bother you, it's just it seems like this issue was overlooked. |
I also encountered this problem, it's frustrating. |
Describe the bug
I have a
TextBox
input which is bound to anint
property in the view model. First I enter1234567890
which is a validint
value. Then I add two more1
s:123456789011
and see a validation error. Then I remove one1
from the end and the validation message is updated. Then I remove another1
and the validation message should be reset but I still see the previous validation message.To Reproduce
int
property:TextBox
bound to the property:123456789011
.1
s usingBackspace
.Expected behavior
The validation error should be gone but it isn't.
Avalonia version
From 11.1.0-rc1 to the latest one which is currently 11.2.0-beta1.
OS
No response
Additional context
The text was updated successfully, but these errors were encountered: