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

Fixes spurious DataGrid data validation error #15716

Merged
merged 2 commits into from
May 14, 2024

Conversation

grokys
Copy link
Member

@grokys grokys commented May 14, 2024

What does the pull request do?

Usually it is not necessary to provide the target property when creating a BindingExpression because the property will be assigned when the binding expression is attached to the target in BindingExpressionBase.Attach.

This is however one case where Attach is not called: when the obsolete binding.Initiate method is called and then an observable is read from the InstancedBinding without the binding actually being attached to the target object. In this case, prior to the binding refactor in #13970 the value produced by the observable was still converted to the target type. After #13970, because the target property (and hence the target type) is not yet set, the conversion is to the target type is no longer done.

DataGrid uses this obsolete method when editing cells, causing #15081. Ideally we'd fix that in DataGrid but I'm not happy making this change so close to 11.1, so instead fix this use-case to behave as before.

Fixed issues

Fixes #15081

Usually it is not necessary to provide the target property when creating a `BindingExpression` because the property will be assigned when the binding expression is attached to the target in `BindingExpressionBase.Attach`.

This is however one case where `Attach` is not called: when the obsolete `binding.Initiate` method is called and then an observable is read from the `InstancedBinding` without the binding actually being attached to the target object. In this case, prior to the binding refactor in #13970 the value produced by the observable was still converted to the target type. After #13970, because the target property (and hence the target type) is not yet set, the conversion is to the target type is no longer done.

`DataGrid` uses this obsolete method when editing cells, causing #15081. Ideally we'd fix that in `DataGrid` but I'm not happy making this change so close to 11.1, so instead fix this use-case to behave as before.

Fixes #15081
@grokys grokys added bug backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels May 14, 2024
@avaloniaui-bot
Copy link

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

@maxkatz6 maxkatz6 added this pull request to the merge queue May 14, 2024
Merged via the queue into master with commit 8fe6e08 May 14, 2024
12 checks passed
@maxkatz6 maxkatz6 deleted the fixes/15081-datagrid-data-validation-error branch May 14, 2024 10:45
grokys added a commit that referenced this pull request Jun 3, 2024
* Added failing tests for #15081.

* Provide target property in BindingExpression ctor.

Usually it is not necessary to provide the target property when creating a `BindingExpression` because the property will be assigned when the binding expression is attached to the target in `BindingExpressionBase.Attach`.

This is however one case where `Attach` is not called: when the obsolete `binding.Initiate` method is called and then an observable is read from the `InstancedBinding` without the binding actually being attached to the target object. In this case, prior to the binding refactor in #13970 the value produced by the observable was still converted to the target type. After #13970, because the target property (and hence the target type) is not yet set, the conversion is to the target type is no longer done.

`DataGrid` uses this obsolete method when editing cells, causing #15081. Ideally we'd fix that in `DataGrid` but I'm not happy making this change so close to 11.1, so instead fix this use-case to behave as before.

Fixes #15081
@grokys grokys added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

11.1.0-beta1 Exception occurred while editing DataGrid
3 participants