Skip to content
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

Converter for DataValidationErrors #11282

Merged
merged 15 commits into from
Nov 7, 2023

Conversation

timunie
Copy link
Contributor

@timunie timunie commented May 8, 2023

What does the pull request do?

Adds a converter attached property to control how DataValidation messages are shown

What is the current behavior?

No easy way to modiy the displayed messages.

What is the updated/expected behavior with this PR?

Easy to use converter attached

How was the solution implemented (if it's not obvious)?

See new sample page

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0034392-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@timunie
Copy link
Contributor Author

timunie commented May 8, 2023

For reference #11234 (comment)

timunie added 3 commits May 10, 2023 15:07
- the converter can be used to change the way a message is print
- we use DisplayErrors to get the converted error messages
@timunie timunie force-pushed the feat/DataValidationConverter branch from 9b7b086 to 228e7c9 Compare May 10, 2023 13:07
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0034547-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

this approach gets rid of the need to DisplayErrors property
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0034549-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037161-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0038250-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0039060-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 marked this pull request as ready for review November 4, 2023 05:59
@timunie
Copy link
Contributor Author

timunie commented Nov 6, 2023

@maxkatz6 I tried your changes and I think these are a useful addition. Now I need to write some docs before 11.1 is released.

Thx ❤️

@timunie timunie changed the title [WIP] Converter for DataValidationErrors Converter for DataValidationErrors Nov 6, 2023
@timunie timunie enabled auto-merge November 6, 2023 12:42
@timunie timunie disabled auto-merge November 6, 2023 12:57
@timunie
Copy link
Contributor Author

timunie commented Nov 6, 2023

@maxkatz6 we have a failing test here:

public void Setter_Exceptions_Should_Set_DataValidationErrors_Errors()
{
using (UnitTestApplication.Start(Services))
{
var target = new TextBox
{
DataContext = new ExceptionTest(),
[!TextBox.TextProperty] = new Binding(nameof(ExceptionTest.LessThan10), BindingMode.TwoWay),
Template = CreateTemplate(),
};
target.ApplyTemplate();
Assert.Null(DataValidationErrors.GetErrors(target));
target.Text = "20";
IEnumerable<object> errors = DataValidationErrors.GetErrors(target);
Assert.Single(errors);
Assert.IsType<InvalidOperationException>(errors.Single());
target.Text = "1";
Assert.Null(DataValidationErrors.GetErrors(target));
}
}

Do you know how to solve it?

@maxkatz6 maxkatz6 enabled auto-merge November 7, 2023 01:29
@maxkatz6 maxkatz6 added this pull request to the merge queue Nov 7, 2023
Merged via the queue into AvaloniaUI:master with commit 8fc0be8 Nov 7, 2023
6 checks passed
@timunie timunie deleted the feat/DataValidationConverter branch November 7, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants