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

Add DoNothingForNullConverter to Fix Color Palette Binding #8829

Merged
merged 2 commits into from
Sep 8, 2022

Conversation

robloo
Copy link
Contributor

@robloo robloo commented Aug 26, 2022

What does the pull request do?

Fixes binding of the nullable selected palette color with the non-nullable Color property within the ColorView.

This issue was first discovered in the Windows Community Toolkit:

What is the current behavior?

Avalonia behaves differently than WinUI/UWP. Instead of just throwing binding errors, Avalonia will clear the color (set it to the default #00000000 when null is attempted to be set).

This results in the color disappearing when opening with the palette tab selected.

Issue.mp4

What is the updated/expected behavior with this PR?

This PR fixes the issue of reset colors by simply ignoring binding updates when null is encountered in this situation. The simple DoNothingForNullConverter enables binding of a non-nullable with nullable property in this scenario.

Fix.mp4

Checklist

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

None opened for this

@avaloniaui-team
Copy link
Contributor

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

@robloo
Copy link
Contributor Author

robloo commented Sep 2, 2022

This PR shouldn't break anything and would be good to merge as a non-breaking bug fix. I notice you are only merging fixes right now.

@maxkatz6 maxkatz6 enabled auto-merge September 8, 2022 08:41
@maxkatz6 maxkatz6 merged commit 8a8e805 into AvaloniaUI:master Sep 8, 2022
@avaloniaui-team
Copy link
Contributor

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

@robloo robloo deleted the colorpicker-palette-binding-fix branch September 8, 2022 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants