-
Notifications
You must be signed in to change notification settings - Fork 80
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
SwitchPresenter 2.0 and the new SwitchConverter 🦙❤️ #550
Conversation
feef7e3
to
9e9fdf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, works and looks good. No major callouts, especially as it's an improvement to an existing component.
components/Primitives/samples/SwitchPresenter/SwitchConverterBrushSample.xaml
Outdated
Show resolved
Hide resolved
Added a basic (but hopefully thorough) unit test based on the sample for Switch Presenter. Ran into some issues, so opened a tracking issue here: CommunityToolkit/Tooling-Windows-Submodule#227 Pushing what I have to check against the CI, ran this test fine locally though (at least on WASDK). Want to add one for the SwitchConverter in the morning, then we should be gtg! |
Though this sample is still broken with NAOT on WinUI 3... :( Tried a couple of the suggested workarounds, but they did not work on my machine, see #516
…object Content for a Data Transformation with ContentTemplate Tested on UWP, WinUI 3, and Uno WASM
Migrate core logic from SwitchPresenter and generlize to share between both SwitchPresenter and SwitchConverter Added small demo of SwitchConverter to SwitchPresenter docs Tested on UWP, WinUI 3, and Uno Platform
…sed on PR feedback
Validates the value changes, the case, and the content
Fix test header (failure in CI from last commit)
7558d36
to
f47c4f6
Compare
TIL, apparently a similar
I hadn't seen any of this before, especially when I created But |
Fixes
Note this does not make an attempt at #516 for WinUI 3, that issue still needs resolution orthogonal to these changes. The specific new functionality works fine and has been tested on UWP, WinUI 3, and Uno Platform WASM.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
ContentPresenter.Content
is anobject
and can take general values/objects beyond just UIElements as it can use aContentTemplate
to transform that into UIElements.This ability has been missing in
SwitchPresenter
asCase.Content
was restricted toUIElement
only.We also have been able to use the same switch like power for transforming values within bindings/expressions.
What is the new behavior?
Case.Content
is now anobject
SwitchPresenter.ContentTemplate
and transform data in new ways within the confines of XAMLDataTemplate
, see new sample.SwitchHelpers
internal static class and generalizedSwitchConverter
SwitchConverter
! This infuses the power ofSwitchPresenter
into aIValueConverter
and allows you to easily transform possible values into resources, like brushes.PR Checklist
Please check if your PR fulfills the following requirements:
Other information
Note: This couldn't have been done from Labs as
SwitchConverter
requires the change in the baseCase.Content
toobject
as well to function, so everything would have to be duplicated. Enabling new scenarios forSwitchPresenter
and sharing the code makes the most sense here.