-
Notifications
You must be signed in to change notification settings - Fork 356
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
For All CommunityToolkit.Maui.Behavior
s, Ensure BindingContext
Is Automatically Set to the Attached View's BindingContext
#1791
For All CommunityToolkit.Maui.Behavior
s, Ensure BindingContext
Is Automatically Set to the Attached View's BindingContext
#1791
Conversation
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.
it looks a lot of work, great that you could fit it soo fast! I've some points there
src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/BasePlatformBehavior.shared.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/BasePlatformBehavior.shared.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/BasePlatformBehavior.shared.cs
Show resolved
Hide resolved
...munityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/Validators/MultiValidationBehavior.shared.cs
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/Validators/MultiValidationBehavior.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/BasePlatformBehavior.shared.cs
Outdated
Show resolved
Hide resolved
Does the BaseBehavior need to account for being attached to multiple Since specifically the |
Good question - yes! I followed the existing pattern I found in |
Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
…ttps://github.com/CommunityToolkit/Maui into Update-All-Behaviors-to-Inherit-from-`BaseBehavior`
Ok gang! I think this is ready to go. I refactored a couple things just now:
|
@brminnick @pictos |
Description of Change
The goal of this Pull Request is to ensure that every
Behavior
inCommunityToolkit.Maui.Behavior
automatically set's the itsBindingContext
to match theBindingContext
of the attachedView
.This PR creates/updates the following classes/interfaces:
ICommunityToolkitBehavior
- an interface meant for internal consumption, used to align the functionality ofBaseBehavior
andBasePlatformBehavior
BaseBehavior : ICommunityToolkitBehavior
BaseBehavior
now implementsICommunityToolkitBehavior
BasePlatformBehavior<TView> : BasePlatformBehavior<TView, PlatformView> where TView : Element
PlatformView
for each operating systemBasePlatformBehavior<TView, TPlatformView> : PlatformBehavior<TView, TPlatformView>, ICommunityToolkitBehavior<TView> where TView : Element where TPlatformView : class
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
The unit tests for
BasePlatformBehavior
can't testOnAttachedTo()
becauseOnAttachedTo()
is only called in platform-specific code forMicrosoft.Maui.Controls.PlatformBehavior
.I also updated the Unit Tests to use Collection Expressions for a small performance bump.