# PropertyBindingMixins

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/mixins/trait-propertybindingmixins/

**trait** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
trait PropertyBindingMixins<V: IViewFor + INotifyPropertyChanged + 'static>
```

The bindings of a view to its view model (`ReactiveUIBindingExtensions.OneWayBind`, `Bind`, and
their forms of `ReactiveSchedulerExtensions`); implemented for every `Rc<V>` of a view `V`.

**The view model.** A view typed for the view model (one that implements
`IViewForOf<VM>`, as `view_for!` writes it) binds
through its own view model: the binding follows the view's `ViewModel`, so that replacing the
view model (with the view raising `PropertyChanged` for `ViewModel`) rebinds, and a view without
one waits for it; `view_model` only names its type. A view that names no type of view model
binds the `view_model` handed in. A binding with no view model binds nothing, and does not fail.

**The writes.** The view property is written on the thread that owns the view (through the
registered `IViewThreadInvoker`), or on the scheduler the call
names, and only when it does not hold the value already. A two-way binding seeds the view from
the view model, then mirrors each later change of either side; the view's own value at the start
is not written back.

**The conversions.** Without functions, a value is converted by the converter the call names,
else by the one registered for the pair of types in
`BindingConverters`, else passed when it already is of the target
type; a value that cannot be converted is not written.

A registered `IPropertyBindingHook` may refuse a binding: the
method then returns `None`. The binding holds its view weakly in its writes; the
[`IReactiveBinding`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-ireactivebinding/) it returns holds it.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L70)

## Members

- [`one_way_bind`](#function-one_way_bind)
- [`one_way_bind_select`](#function-one_way_bind_select)
- [`one_way_bind_select_on`](#function-one_way_bind_select_on)
- [`one_way_bind_with`](#function-one_way_bind_with)
- [`bind`](#function-bind)
- [`bind_select`](#function-bind_select)
- [`bind_select_on`](#function-bind_select_on)
- [`bind_with`](#function-bind_with)
- [`bind_with_trigger`](#function-bind_with_trigger)
- [`bind_select_with_trigger`](#function-bind_select_with_trigger)

<a id="function-one_way_bind"></a>

### one_way_bind

```rust
fn one_way_bind<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

Binds `view_model_property` one way to `view_property`: the current value and each later
change are written to the view (`OneWayBind(TViewModel?, Expression, Expression)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L77)

<a id="function-one_way_bind_select"></a>

### one_way_bind_select

```rust
fn one_way_bind_select<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, selector: impl Fn(TVM) -> TV + 'static) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`one_way_bind` through `selector`
(`OneWayBind(TViewModel?, Expression, Expression, Func<TProp, TOut>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L93)

<a id="function-one_way_bind_select_on"></a>

### one_way_bind_select_on

```rust
fn one_way_bind_select_on<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, selector: impl Fn(TVM) -> TV + 'static, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`one_way_bind_select`, writing on `scheduler`, or on the
view's thread when it is `None` (`ReactiveSchedulerExtensions.OneWayBind(..., Func<TProp,
TOut>, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L111)

<a id="function-one_way_bind_with"></a>

### one_way_bind_with

```rust
fn one_way_bind_with<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, converter: Option<Rc<dyn IBindingTypeConverter>>, conversion_hint: Option<Rc<dyn Any>>, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`one_way_bind`, converting with `converter` instead of a registered
converter when it is given, with `conversion_hint`, and writing on `scheduler`, or on the
view's thread when it is `None` (`ReactiveSchedulerExtensions.OneWayBind(...,
IBindingTypeConverter, object?, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L131)

<a id="function-bind"></a>

### bind

```rust
fn bind<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

Binds `view_model_property` and `view_property` to each other: the view is seeded from the
view model, then each change of either side is written to the other
(`Bind(TViewModel?, Expression, Expression)`). The change stream of the binding reports each
value written, with the side it came from.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L159)

<a id="function-bind_select"></a>

### bind_select

```rust
fn bind_select<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`bind` through `view_model_to_view` and `view_to_view_model`
(`Bind(TViewModel?, Expression, Expression, Func<TVMProp, TVProp>, Func<TVProp, TVMProp>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L183)

<a id="function-bind_select_on"></a>

### bind_select_on

```rust
fn bind_select_on<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`bind_select`, writing to the view on `scheduler`, or on the view's
thread when it is `None`; on a scheduler, only the latest value that waits is written
(`ReactiveSchedulerExtensions.Bind(..., Func, Func, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L210)

<a id="function-bind_with"></a>

### bind_with

```rust
fn bind_with<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view_converter: Option<Rc<dyn IBindingTypeConverter>>, view_to_view_model_converter: Option<Rc<dyn IBindingTypeConverter>>, conversion_hint: Option<Rc<dyn Any>>, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static
```

`bind`, converting with `view_model_to_view_converter` and
`view_to_view_model_converter` instead of the registered converters when they are given,
with `conversion_hint`, and writing to the view on `scheduler`, or on the view's thread when
it is `None` (`ReactiveSchedulerExtensions.Bind(..., IBindingTypeConverter,
IBindingTypeConverter, object?, ISequencer?)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L241)

<a id="function-bind_with_trigger"></a>

### bind_with_trigger

```rust
fn bind_with_trigger<VM, TVM, TV, D>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, signal_view_update: Option<Rc<dyn IObservable<D>>>, trigger_update: TriggerUpdate) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static,
      D: 'static
```

Binds `view_model_property` and `view_property` to each other, driven by direction
signals (`BindUnsafe(..., IObservable<TDontCare>? signalViewUpdate, TriggerUpdate)`).

Without `signal_view_update`, a change of either side is written to the other. With it,
`TriggerUpdate::ViewToViewModel` writes the view to the view model only when the stream
produces a value (the changes of the view are not observed), and
`TriggerUpdate::ViewModelToView` writes the view model to the view only when the stream
produces a value (the changes of the view are still written back). The current values are
read on the view's thread when a signal is delivered, so a signal that waited writes the
values of its delivery. The view is always initialized from the view model.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L277)

<a id="function-bind_select_with_trigger"></a>

### bind_select_with_trigger

```rust
fn bind_select_with_trigger<VM, TVM, TV, D>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static, signal_view_update: Option<Rc<dyn IObservable<D>>>, trigger_update: TriggerUpdate) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
      TVM: Clone + PartialEq + 'static,
      TV: Clone + PartialEq + 'static,
      D: 'static
```

`bind_with_trigger` through `view_model_to_view` and
`view_to_view_model` (`BindUnsafe(..., Func, Func, IObservable<TDontCare>?, TriggerUpdate)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/mixins/reactive_ui_binding_extensions_binding.rs#L306)

## Trait implementations

- [`PropertyBindingMixins<V>`](/docs/0.5.0/api/ferroui-reactiveui/binding/mixins/trait-propertybindingmixins/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
