The recording of the first ever ReactiveUI virtual conference is available on our YouTube Channel.

PropertyBindingMixins.

OneWayBind<TViewModel, TView, TProp, TOut>(TView, TViewModel, Expression<Func<TViewModel, TProp>>, Expression<Func<TView, TOut>>, Func<TProp, TOut>) Method

Summary

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.
Namespace
ReactiveUI
Containing Type
PropertyBindingMixins

Syntax

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

Type Parameters

Name Description
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.

Parameters

Name Type Description
view TView The 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.

Return Value

Type Description
IReactiveBinding<TView, TOut> An instance of IDisposable that, when disposed, disconnects the binding.