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: Fix color picker button binding failure issue #4730

Conversation

HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Aug 18, 2022

Fixes

Fixes #4721

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The current SelectedValue binding throws a Binding Failure error because it tries to return a null Color property (due to BindingMode=TwoWay) that has a value type

What is the new behavior?

Added a helper converter that will ignore null values in ConvertBack, replacing them with DependencyProperty.UnsetValue

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Aug 18, 2022

Thanks HavenDV for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker and azchohfi August 18, 2022 06:13
@ghost ghost added bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ WinUI 💠 Related to WinUI 3 Version or when paired with External can mean requires fix in WinUI 2/3. labels Aug 18, 2022
@michael-hawker michael-hawker added this to the 7.1.3 milestone Aug 18, 2022
@michael-hawker
Copy link
Member

@robloo mind having a quick look if you have a few minutes?

@robloo
Copy link
Contributor

robloo commented Aug 18, 2022

I'll look at the last few issues and this together. Please give me this weekend to do it though.

@robloo
Copy link
Contributor

robloo commented Aug 20, 2022

I confirmed the issue and this fix looks fine to me. It just never allows setting null to the non-nullable ColorPicker.Color property which would otherwise occur when no color is selected in the palette.

It is unfortunate another converter is needed for this but I can't think of a better way.

@robloo
Copy link
Contributor

robloo commented Aug 26, 2022

Note that I made a more general-purpose converter in Avalonia to fix this. I'm not asking for any changes here but just FYI:

https://github.com/AvaloniaUI/Avalonia/pull/8829/files

Copy link

@niels9001 niels9001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in the sample app by setting the SelectedColor to {x:Null}. It was throwing binding errors in the current build, this PR resolved that 😊. Great work @HavenDV - LGTM!

@michael-hawker michael-hawker force-pushed the fix-color-picker-button-binding-issue branch from ca1ad1f to 7f49e98 Compare October 18, 2022 16:31
@michael-hawker michael-hawker merged commit 5d90149 into CommunityToolkit:main Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior controls 🎛️ WinUI 💠 Related to WinUI 3 Version or when paired with External can mean requires fix in WinUI 2/3.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ColorPickerButton Binding errors
4 participants