Fix interaction of RadioButton, shared bindings and hanging GC refs #10252
+74
−70
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.
Fixes #9035
Fixes #2995
Marking it as draft right now due to the changes from #10251 being included. Only the latest commit is relevant.
Description
This fixes actually two things, not just one and I'm fine with only fixing the #2995 / #9035 if desirable.
First fix
First fix resolves #2995 / #9035 report that was also attempted in #8202 but was reverted in #10105 due to obvious issues.
Original method compares the visual root that's found using the following:
The problem being that this search will result in
null
on Popups (hence why the original fix caused #10087), it will returnnull
on radio buttons with closed Windows and depending on the focus situation it may returnnull
on a fresh window.Using
InputElement.GetRootVisual
instead we will retrieve the proper visual roots for Popups (PopupRoot), for open windows right after creation and for non-GCedRadioButton
's but detached from their visual root it will retrieve the container.Second fix/improvement
The original issue attempts to share a binding between two distincts visual roots using a singleton instance, which works until you have a hanging not-yet GCed
RadioButton
due to the reasons described in the first fix.Excuse the checking verbosity, however, this would allow for shared bindings (e.g. here - #2995 (comment)) to continue working properly even under the same visual root instead of just bound property being always set to
false
. All while retaining the usual RadioButton behavior and functionality. Can be simulated in updated repro with more stuff here - RadioButton.GroupName.Tests. You'll have to update theReferences
though.Customer Impact
Resolving long standing issues concerning
RadioButton
and bindings.Regression
No.
Testing
Local build, extensive testing with multiple reproduction samples.
Risk
More testing is needed of course, but it would be a nice improvement to have this working. The second fix changes behavior, but changes it from non-working and appearing buggy to actually working nicely.
Microsoft Reviewers: Open in CodeFlow