Replies: 1 comment 2 replies
-
Avalonia 11.1 still has InstancedBinding.TwoWay static method:
which you should be able to use:
Whole InstancedBinding is planned to be removed in 12, but we still have some time before that. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One can easily bind to regular
IObservable<T>
from xaml by usingObservablePropertyName^
syntax.However this is only good for one-way binding, i.e. where UI gets updated in response to observable's changes.
For 2-way binding it seems we always need
INotifyPropertyChanged
. However this seems to be somewhat inefficient for many scenarios - often there would be just one property on an object that could change, and dealing with string comparisons of property names at runtime seems wasteful. So, is there a way to have anIObservable<T>
style binding that will work both ways, i.e. it will be able to convey back changes from the UI to the actual property type. Of course that type can't be justIObservable<T>
since it will need to have a way to accept new values. So perhaps it can be something likeSubject<T>
, which is both anIObservable<T>
, andIObserver<T>
.My understanding is that there is no such thing out of the box in Avalonia and there are no plans to support it, so that for XAML we would continue to rely on dated
INotifyPropertyChanged
approach. Can someone correct me if I am wrong?Another question is - is it possible to implement such a functionality by creating a custom Binding-like Markup extension that will work with Avalonia XAML compiler? If so, can someone suggest a rough approach as how this can be done. At least in terms of creating custom markup extensions.
Beta Was this translation helpful? Give feedback.
All reactions