[Binding SG] Add an API for creating instances of TypedBinding#23239
Merged
PureWeen merged 17 commits intodotnet:net9.0from Jul 15, 2024
Merged
[Binding SG] Add an API for creating instances of TypedBinding#23239PureWeen merged 17 commits intodotnet:net9.0from
PureWeen merged 17 commits intodotnet:net9.0from
Conversation
a75ab00 to
abd3426
Compare
|
|
||
| namespace Microsoft.Maui.Controls | ||
| { | ||
| public static class BindingFactory |
Member
There was a problem hiding this comment.
@StephaneDelcroix what do you think about just putting the method here on Binding?
…factory-generated-bindings-api
…factory-generated-bindings-api
This was referenced Jul 2, 2024
…factory-generated-bindings-api
jonathanpeppers
approved these changes
Jul 3, 2024
Member
jonathanpeppers
left a comment
There was a problem hiding this comment.
I reran some tests, as I think the Xcode provisionator failures are fixed now.
Comment on lines
+20
to
+23
| /// <param name="targetNullValue">The value to supply for a bound property when the target of the binding is <see langword="null" />.</param> | ||
| /// <exception cref="ArgumentNullException"></exception> | ||
| [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCodeMessage", | ||
| Justification = "The Binding.Create<TSource, TProperty>() method does not create an instance of Binding but an instance of TypedBinding<TSource, TProperty>.")] |
Member
There was a problem hiding this comment.
Seems like there might be mixed tabs/spaces in this file.
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
|
Having a Binding.Create() method allows the capture of the binding, and potentially a reuse of it, which isn't supported. I would stick with SetBinding... |
Member
|
@StephaneDelcroix I think the three examples are |
StephaneDelcroix
approved these changes
Jul 15, 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
We recently enabled a source generator that allows developers to call the
SetBindingextension method to define bindings on their bindable objects usingFuncinstead of string paths. This PR builds on top of that feature and adds a second supported API that will not only set the binding directly to the object, but it will return the binding object instance and allow the developer to pass it to some other method and use it later.Use-cases
1. Setters
Before:
maui/src/Controls/src/Core/Shell/BaseShellItem.cs
Lines 429 to 433 in 0572098
After:
2.
DataTrigger:Before:
maui/src/Compatibility/ControlGallery/src/Issues.Shared/Bugzilla57910.cs
Lines 60 to 61 in c564156
After:
3.
MultiBindingBefore:
maui/src/Controls/tests/Core.UnitTests/MultiBindingTests.cs
Lines 68 to 78 in c564156
After:
Issues Fixed
Contributes to #22384
/cc @jkurdek @StephaneDelcroix @jonathanpeppers