Class PropertyBinderImplementation
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
Provides methods to bind properties to observables.
- Inheritance
-
Property
Binder Implementation
- Implements
-
IEnable
Logger
- Extension Methods
Constructors
PropertyBinderImplementation()
Methods
BindTo<TValue, TTarget, TTValue>(IObservable<TValue>, TTarget?, Expression<Func<TTarget, TTValue?>>, object?, IBindingTypeConverter?)
BindTo takes an Observable stream and applies it to a target property. Conceptually it is similar to.
Subscribe(x =>
target.property = x), but allows you to use child properties
without the null checks.
public IDisposable BindTo<TValue, TTarget, TTValue>(IObservable<TValue> observedChange, TTarget? target, Expression<Func<TTarget, TTValue?>> propertyExpression, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class
Parameters
observedChangeIObservable<TValue>The target observable to bind to.
targetTTargetThe target object whose property will be set.
propertyExpressionExpression<Func<TTarget, TTValue>>An expression representing the target property to set. This can be a child property (i.e.
x.Foo.Bar.Baz).conversionHintobjectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverrideIBindingType Converter An optional IBinding
Type to use when converting from the viewModel to view property.Converter
Returns
- IDisposable
An object that when disposed, disconnects the binding.
Type Parameters
TValueThe value type.
TTargetThe target type.
TTValueThe target value type.
Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel?, TView, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, IObservable<TDontCare>?, Func<TVMProp?, TVProp>, Func<TVProp, TVMProp?>, TriggerUpdate)
Creates a two-way binding between a view model and a view.
This binding will attempt to convert the values of the
view and view model properties using a IBinding
public IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, IObservable<TDontCare>? signalViewUpdate, Func<TVMProp?, TVProp> vmToViewConverter, Func<TVProp, TVMProp?> viewToVmConverter, TriggerUpdate triggerUpdate = TriggerUpdate.ViewToViewModel) where TViewModel : class where TView : class, IViewFor
Parameters
viewModelTViewModel The instance of the view model object to be bound.
viewTViewThe instance of the view object to be bound.
vmPropertyExpression<Func<TViewModel, TVMProp>>An expression representing the property to be bound to on the view model. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get and set the correct property.viewPropertyExpression<Func<TView, TVProp>>An expression representing the property to be bound to on the view. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get and set the correct property.signalViewUpdateIObservable<TDontCare>An observable, that when signaled, indicates that the view property has been changed, and that the binding should update the view model property accordingly.
vmToViewConverterFunc<TVMProp, TVProp>Delegate to convert the value of the view model's property's type to a value of the view's property's type.
viewToVmConverterFunc<TVProp, TVMProp>Delegate to convert the value of the view's property's type to a value of the view model's property's type.
triggerUpdateTriggerUpdate The trigger update direction.
Returns
- IReactive
Binding <TView, (object view, bool isView )>Model An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model that is bound.
TViewThe type of the view being bound.
TVMPropThe type of the property bound on the view model.
TVPropThe type of the property bound on the view.
TDontCareA dummy type, only the fact that
signalViewUpdateemits values is considered, not the actual values emitted.
Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel?, TView, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, IObservable<TDontCare>?, object?, IBindingTypeConverter?, IBindingTypeConverter?, TriggerUpdate)
Creates a two-way binding between a view model and a view.
This binding will attempt to convert the values of the
view and view model properties using a IBinding
public IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, IObservable<TDontCare>? signalViewUpdate, object? conversionHint, IBindingTypeConverter? vmToViewConverterOverride = null, IBindingTypeConverter? viewToVMConverterOverride = null, TriggerUpdate triggerUpdate = TriggerUpdate.ViewToViewModel) where TViewModel : class where TView : class, IViewFor
Parameters
viewModelTViewModel The instance of the view model object to be bound.
viewTViewThe instance of the view object to be bound.
vmPropertyExpression<Func<TViewModel, TVMProp>>An expression representing the property to be bound to on the view model. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get and set the correct property.viewPropertyExpression<Func<TView, TVProp>>An expression representing the property to be bound to on the view. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get and set the correct property.signalViewUpdateIObservable<TDontCare>An observable, that when signaled, indicates that the view property has been changed, and that the binding should update the view model property accordingly.
conversionHintobjectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverrideIBindingType Converter An optional IBinding
Type to use when converting from the viewModel to view property.Converter viewToVMConverterOverrideIBindingType Converter An optional IBinding
Type to use when converting from the view to viewModel property.Converter triggerUpdateTriggerUpdate The trigger update direction.
Returns
- IReactive
Binding <TView, (object view, bool isView )>Model An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model that is bound.
TViewThe type of the view being bound.
TVMPropThe type of the property bound on the view model.
TVPropThe type of the property bound on the view.
TDontCareA dummy type, only the fact that
signalViewUpdateemits values is considered, not the actual values emitted.
OneWayBind<TViewModel, TView, TProp, TOut>(TViewModel?, TView, Expression<Func<TViewModel, TProp>>, Expression<Func<TView, TOut>>, Func<TProp, TOut>)
Creates a one way binding with a selector, i.e. a binding that flows from the
viewModel to the view only, and where the value of the view model
property is mapped through the selector before being set to the view.
public IReactiveBinding<TView, TOut> OneWayBind<TViewModel, TView, TProp, TOut>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TProp>> vmProperty, Expression<Func<TView, TOut>> viewProperty, Func<TProp, TOut> selector) where TViewModel : class where TView : class, IViewFor
Parameters
viewModelTViewModel The instance of the view model to bind to.
viewTViewThe instance of the view to bind to.
vmPropertyExpression<Func<TViewModel, TProp>>An expression representing the property to be bound to on the view model. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get the last value of the property chain.viewPropertyExpression<Func<TView, TOut>>An expression representing the property to be bound to on the view. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always set the correct property.selectorFunc<TProp, TOut>A function that will be used to transform the values of the property on the view model before being bound to the view property.
Returns
- IReactive
Binding <TView, TOut> An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model that is bound.
TViewThe type of the view that is bound.
TPropThe type of the property bound on the view model.
TOutThe return type of the
selector.
OneWayBind<TViewModel, TView, TVMProp, TVProp>(TViewModel?, TView, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, object?, IBindingTypeConverter?)
Creates a one-way binding, i.e. a binding that flows from the
viewModel to the view only. This binding will
attempt to convert the value of the view model property to the view property if they
are not of the same type.
public IReactiveBinding<TView, TVProp> OneWayBind<TViewModel, TView, TVMProp, TVProp>(TViewModel? viewModel, TView view, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, IViewFor
Parameters
viewModelTViewModel The instance of the view model to bind to.
viewTViewThe instance of the view to bind to.
vmPropertyExpression<Func<TViewModel, TVMProp>>An expression representing the property to be bound to on the view model. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always get the last value of the property chain.viewPropertyExpression<Func<TView, TVProp>>An expression representing the property to be bound to on the view. This can be a child property, for example
x => x.Foo.Bar.Bazin which case the binding will attempt to subscribe recursively to updates in order to always set the correct property.conversionHintobjectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverrideIBindingType Converter An optional IBinding
Type to use when converting from the viewModel to view property.Converter
Returns
- IReactive
Binding <TView, TVProp> An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModelThe type of the view model that is bound.
TViewThe type of the view that is bound.
TVMPropThe type of the property bound on the view model.
TVPropThe type of the property bound on the view.
Exceptions
- Argument
Exception There is no registered converter from
TVMProptoTVProp.