Always propagate the BC to the ControlTemplate#26072
Merged
Conversation
mattleibow
reviewed
Nov 22, 2024
StephaneDelcroix
previously approved these changes
Nov 22, 2024
Contributor
StephaneDelcroix
left a comment
There was a problem hiding this comment.
provided we restore the warnings as errors if possible
9fd12e7 to
fc7ab11
Compare
rmarinho
approved these changes
Nov 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
With the initial design of Xamarin.Forms the BC would never propagate to the ControlTemplate as we can see from the test
DoesNotInheritBindingContextToTemplatethat you can reference inside this PR.I'm not really clear on the initial reasoning here. I've compared the behavior to a
ContentControlin WinUI and the DataContext inWinUIalways propagates to the Template and theDataContexton theContentViewalways propagates to theContentPresentereven if the template changes theDataContextWe changed this behavior in a slightly awkward way in net8.0 #12536 where we are only setting the
ControlTemplateBC when theContentisn't set and it only works for the initialControlTemplatesince we didn't copy this logic intoControlTemplateChangedIt's also a bit weird now because the ordering will change how the BC gets assigned. For example,
This will cause the BC to propagate to the
ControlTemplatebut now it won't propagate when you change theControlTemplate. Which is basically what the issue this is fixing is seeing happen.This PR fully commits in the direction of just setting the
ControlTemplatesbinding context always from theContentView'sBindingContextIssues Fixed
Fixes #25934
Fixes #22607
Fixes #14919