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

Fix bindings without property path #16729

Merged
merged 3 commits into from
Sep 14, 2024

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Aug 19, 2024

What does the pull request do?

This PR fixes bindings that are directly bound to a data context without any property path (e.g. {Binding}).

#13970 / v11.1 introduced a subtle change:

  • In v11.0, a null data context is considered unset, whether there's a binding path or not.
  • In v11.1, a null data context is considered unset when there's a binding path, or a valid null value if there isn't one.

While both results make sense, this is a behavioral breaking change from v11.0:

  • OneTime bindings when the data context isn't known yet don't work anymore.
  • NullTargetValue and StringFormat are being applied to the null data context.

This PR restores the 11.0 behavior.
Unit tests have been added.

For the rare cases where binding directly to a null data context is effectively expected (with a TargetNullValue set), we could add a new binding option in the future.

Fixed issues

@avaloniaui-bot
Copy link

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

@maxkatz6 maxkatz6 requested a review from grokys August 21, 2024 06:20
@workgroupengineering
Copy link
Contributor

I tried it and it works as expected. Will it be backported or will the fix be released with 11.2?

@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Aug 27, 2024
@avaloniaui-bot
Copy link

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

@maxkatz6 maxkatz6 merged commit 20f77a3 into AvaloniaUI:master Sep 14, 2024
10 checks passed
@MrJul MrJul deleted the fixes/onetime-binding-datacontext branch September 19, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-bindings backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch bug regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding OneTime does not work
5 participants