MultiBinding! (Issue 4565)#8684
Conversation
| internal bool IsTarget { get; } | ||
|
|
||
| public static readonly BindableProperty ValueProperty = BindableProperty.Create( | ||
| "Value", |
StephaneDelcroix
left a comment
There was a problem hiding this comment.
left some remarks, otherwise 👍
thanks for the extensive test suite.
I know there's none in WPF, but what would be a good markup extension for this ? (we can bring that on a different PR)
| public Collection<BindingBase> Bindings | ||
| { | ||
| get => _bindings ?? (_bindings = new Collection<BindingBase>()); | ||
| set => _bindings = value; |
There was a problem hiding this comment.
it should probably throw if applied, and also throw if the collection is modified once the binding is applied
There was a problem hiding this comment.
Ok on throw if applied. To detect collection modified wouldn't it have to be an INCC though? Is it worth it?
There was a problem hiding this comment.
I know there's none in WPF, but what would be a good markup extension for this ? (we can bring that on a different PR)
I was thinking about that myself, but I don't know of any precedent for a collection being represented through a markup extension, do you?
|
Is MultiBinding going to be in 4.5.0? |
|
@AmrAlSayed0 it has not been abandoned but I have been swamped with my actual job. I'm fine with @StephaneDelcroix's changes so if he or anyone wants to just make them and run with this that's fine by me. Otherwise I'll make them when I'm able. |
* Implement MultiBinding for OneWay and TwoWay modes * Make it work with different BindingModes * Add RelativeSource support. * Additional tweaks for edge cases. Add unit tests. * Implement RelativeSourceTargetOverride with a WeakReference * Modify per PR feedback Co-authored-by: Samantha Houts <samhouts@users.noreply.github.com>
e2c3755 to
d6a4985
Compare
|
@StephaneDelcroix I think I'm finished here, just not sure if you actually want me to bother trying to detect binding collection changes through INCC. This should now be properly rebased on 4.6.0 too btw. |
|
Error Position 56:34. Type MultiBinding not found in xmlns http://xamarin.com/schemas/2014/forms Version 4.6.0.726+446-sha.d0dc59903-azdo.3681414 Is this not usable yet? |
|
This will be part of 4.7.0. You may try it in the latest nightly build. Thanks! |
|
I've made a Demo and it works. Using multi binding requires using a converter that implement the logic of multi binding, while using a VM property that implement the same logic but require to notify that that property has changed when the other properties involved in the logic change their values. Having the choice of using multi binding also in Xamarin Forms is a good thing. |
Description of Change
Implements
MultiBinding, per issue #4565.fixes #4565
API Changes
Added:
public sealed class MultiBinding : BindingBasepublic interface IMultiValueConverterpublic static readonly object DoNothing { get; }inBindingpublic static readonly object UnsetValue { get; }inBindableProperty(the last two are used in
IMultiValueConverterimplementations)Platforms Affected
All
Behavioral/Visual Changes
No changes to existing applications.
New applications can now use
MultiBindingto bind a target property to a series ofBindingBaseexpressions (including nestedMultiBindings) that evaluate to a single value through anIMultiValueConverterinstance provided by the application. For example:All types of
Bindings should be valid child bindings for theMultiBinding, including implicit source (BindingContext), explicit sourceBinding, relative sourceBinding, and even additionalMultiBindings.Except for allowing nested
MultiBindings, all efforts have been made to match the WPF spec and behavior for the same feature.Testing Procedure
Unit tests in Xamarin.Forms.Core
PR Checklist