Class PropertyBindingMixins
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
This class provides extension methods for the ReactiveUI view binding mechanism.
- Inheritance
-
Property
Binding Mixins
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 static IDisposable BindTo<TValue, TTarget, TTValue>(this IObservable<TValue> @this, TTarget? target, Expression<Func<TTarget, TTValue?>> property, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null) where TTarget : class
Parameters
this
IObservable<TValue>The observable stream to bind to a target property.
target
TTargetThe target object whose property will be set.
property
Expression<Func<TTarget, TTValue>>An expression representing the target property to set. This can be a child property (i.e.
x.Foo.Bar.Baz
).conversionHint
objectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverride
IBindingType 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
TValue
The source type.
TTarget
The target object type.
TTValue
The type of the property on the target object.
Bind<TViewModel, TView, TVMProp, TVProp>(TView, TViewModel?, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, Func<TVMProp?, TVProp>, Func<TVProp, TVMProp?>)
Binds the specified view model property to the given view property.
public static IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, Func<TVMProp?, TVProp> vmToViewConverter, Func<TVProp, TVMProp?> viewToVmConverter) where TViewModel : class where TView : class, IViewFor
Parameters
view
TViewThe instance of the view to bind.
viewModel
TViewModel The instance of the view model to bind.
vmProperty
Expression<Func<TViewModel, TVMProp>>An expression indicating the property that is bound on the view model. This can be a chain of properties of the form.
vm => vm.Foo.Bar.Baz
and the binder will attempt to subscribe to changes on each recursively.viewProperty
Expression<Func<TView, TVProp>>The property on the view that is to be bound. This can be a chain of properties of the form.
view => view.Foo.Bar.Baz
and the binder will attempt to set the last one each time the view model property is updated.vmToViewConverter
Func<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.
viewToVmConverter
Func<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.
Returns
- IReactive
Binding <TView, (object view, bool isView )>Model An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModel
The type of the view model being bound.
TView
The type of the view being bound.
TVMProp
The type of the property bound on the view model.
TVProp
The type of the property bound on the view.
Bind<TViewModel, TView, TVMProp, TVProp>(TView, TViewModel?, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, object?, IBindingTypeConverter?, IBindingTypeConverter?)
Binds the specified view model property to the given view property.
public static IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null, IBindingTypeConverter? viewToVMConverterOverride = null) where TViewModel : class where TView : class, IViewFor
Parameters
view
TViewThe instance of the view to bind.
viewModel
TViewModel The instance of the view model to bind.
vmProperty
Expression<Func<TViewModel, TVMProp>>An expression indicating the property that is bound on the view model. This can be a chain of properties of the form.
vm => vm.Foo.Bar.Baz
and the binder will attempt to subscribe to changes on each recursively.viewProperty
Expression<Func<TView, TVProp>>The property on the view that is to be bound. This can be a chain of properties of the form.
view => view.Foo.Bar.Baz
and the binder will attempt to set the last one each time the view model property is updated.conversionHint
objectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverride
IBindingType Converter An optional IBinding
Type to use when converting from the viewModel to view property.Converter viewToVMConverterOverride
IBindingType Converter An optional IBinding
Type to use when converting from the view to viewModel property.Converter
Returns
- IReactive
Binding <TView, (object view, bool isView )>Model An instance of IDisposable that, when disposed, disconnects the binding.
Type Parameters
TViewModel
The type of the view model being bound.
TView
The type of the view being bound.
TVMProp
The type of the property bound on the view model.
TVProp
The type of the property bound on the view.
Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TView, TViewModel?, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, IObservable<TDontCare>?, Func<TVMProp?, TVProp>, Func<TVProp, TVMProp?>, TriggerUpdate)
Binds the specified view model property to the given view property.
public static IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(this TView view, TViewModel? viewModel, 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
view
TViewThe instance of the view to bind.
viewModel
TViewModel The instance of the view model to bind.
vmProperty
Expression<Func<TViewModel, TVMProp>>An expression indicating the property that is bound on the view model. This can be a chain of properties of the form.
vm => vm.Foo.Bar.Baz
and the binder will attempt to subscribe to changes on each recursively.viewProperty
Expression<Func<TView, TVProp>>The property on the view that is to be bound. This can be a chain of properties of the form.
view => view.Foo.Bar.Baz
and the binder will attempt to set the last one each time the view model property is updated.signalViewUpdate
IObservable<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.
vmToViewConverter
Func<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.
viewToVmConverter
Func<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.
triggerUpdate
TriggerUpdate 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
TViewModel
The type of the view model being bound.
TView
The type of the view being bound.
TVMProp
The type of the property bound on the view model.
TVProp
The type of the property bound on the view.
TDontCare
A dummy type, only the fact that
signalViewUpdate
emits values is considered, not the actual values emitted.
Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(TView, TViewModel?, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, IObservable<TDontCare>?, object?, IBindingTypeConverter?, IBindingTypeConverter?, TriggerUpdate)
Binds the specified view model property to the given view property, and provide a custom view update signaller to signal when the view property has been updated.
public static IReactiveBinding<TView, (object? view, bool isViewModel)> Bind<TViewModel, TView, TVMProp, TVProp, TDontCare>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, IObservable<TDontCare>? signalViewUpdate, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null, IBindingTypeConverter? viewToVMConverterOverride = null, TriggerUpdate triggerUpdate = TriggerUpdate.ViewToViewModel) where TViewModel : class where TView : class, IViewFor
Parameters
view
TViewThe instance of the view to bind.
viewModel
TViewModel The instance of the view model to bind.
vmProperty
Expression<Func<TViewModel, TVMProp>>An expression indicating the property that is bound on the view model. This can be a chain of properties of the form.
vm => vm.Foo.Bar.Baz
and the binder will attempt to subscribe to changes on each recursively.viewProperty
Expression<Func<TView, TVProp>>The property on the view that is to be bound. This can be a chain of properties of the form.
view => view.Foo.Bar.Baz
and the binder will attempt to set the last one each time the view model property is updated.signalViewUpdate
IObservable<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.
conversionHint
objectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverride
IBindingType Converter An optional IBinding
Type to use when converting from the viewModel to view property.Converter viewToVMConverterOverride
IBindingType Converter An optional IBinding
Type to use when converting from the view to viewModel property.Converter triggerUpdate
TriggerUpdate 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
TViewModel
The type of the view model being bound.
TView
The type of the view being bound.
TVMProp
The type of the property bound on the view model.
TVProp
The type of the property bound on the view.
TDontCare
A dummy type, only the fact that
signalViewUpdate
emits values is considered, not the actual values emitted.
OneWayBind<TViewModel, TView, TProp, TOut>(TView, TViewModel?, Expression<Func<TViewModel, TProp?>>, Expression<Func<TView, TOut>>, Func<TProp, TOut>)
Binds the specified view model property to the given view, in a one-way (view model to view) fashion,
with the value of the view model property mapped through a selector
function.
public static IReactiveBinding<TView, TOut> OneWayBind<TViewModel, TView, TProp, TOut>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TProp?>> vmProperty, Expression<Func<TView, TOut>> viewProperty, Func<TProp, TOut> selector) where TViewModel : class where TView : class, IViewFor
Parameters
view
TViewThe instance of the view to bind to.
viewModel
TViewModel The instance of the view model to bind to.
vmProperty
Expression<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.Baz
in which case the binding will attempt to subscribe recursively to updates in order to always get the last value of the property chain.viewProperty
Expression<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.Baz
in which case the binding will attempt to subscribe recursively to updates in order to always set the correct property.selector
Func<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
TViewModel
The type of the view model that is bound.
TView
The type of the view that is bound.
TProp
The type of the property bound on the view model.
TOut
The return type of the
selector
.
OneWayBind<TViewModel, TView, TVMProp, TVProp>(TView, TViewModel?, Expression<Func<TViewModel, TVMProp?>>, Expression<Func<TView, TVProp>>, object?, IBindingTypeConverter?)
Binds the given property on the view model to a given property on the view in a one-way (view model to view) fashion.
public static IReactiveBinding<TView, TVProp> OneWayBind<TViewModel, TView, TVMProp, TVProp>(this TView view, TViewModel? viewModel, Expression<Func<TViewModel, TVMProp?>> vmProperty, Expression<Func<TView, TVProp>> viewProperty, object? conversionHint = null, IBindingTypeConverter? vmToViewConverterOverride = null) where TViewModel : class where TView : class, IViewFor
Parameters
view
TViewThe instance of the view object which is bound. Usually, it is the.
this
instance.viewModel
TViewModel The view model that is bound. It is usually set to the View
Model property of theview
.vmProperty
Expression<Func<TViewModel, TVMProp>>An expression indicating the property that is bound on the view model. This can be a chain of properties of the form.
vm => vm.Foo.Bar.Baz
and the binder will attempt to subscribe to changes on each recursively.viewProperty
Expression<Func<TView, TVProp>>The property on the view that is to be bound. This can be a chain of properties of the form.
view => view.Foo.Bar.Baz
and the binder will attempt to set the last one each time the view model property is updated.conversionHint
objectAn object that can provide a hint for the converter. The semantics of this object is defined by the converter used.
vmToViewConverterOverride
IBindingType 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
TViewModel
The type of the view model.
TView
The type of the view.
TVMProp
The type of view model property.
TVProp
The type of the property bound on the view.