IBindingAdapter<TControl, TValue> interface Core

How a binding reaches a control that holds its value itself, such as TextBox with its text: read what the control holds now, and show a value that came from the view model. A control whose value is a pair of delegates (Value and Changed or Toggle) needs no adapter: it takes Bound.Get and Bound.Set directly.

Contract. Both members run on the UI thread, under the board's render gate. IBindingAdapter.Show must invalidate the control (as a control's own setter does): the binding learns of an edit through that invalidation, and it reads the control with IBindingAdapter.Read after every change of the board that invalidated it. IBindingAdapter.Read must be cheap and must not allocate when nothing changed: it runs after every input action that repaints the control (the text box returns its buffer's string as it is).

public interface IBindingAdapter<in TControl, TValue> where TControl : Control
Namespace
ArionUI.Presentation.Controls
Package
ArionUI.Presentation · dotnet add package ArionUI.Presentation --prerelease

Type parameters

TControl

The control.

TValue

The value it holds.

Properties

UpdateOn

BindingUpdate UpdateOn { get; }

When the control shows the view model's answer to its own edit; by default at the commit (focus leaves, Enter), so a formatting view model does not rewrite the text under the user's caret.

Methods

Read

TValue Read(TControl control);

What the control holds now.

Show

void Show(TControl control, TValue value);

Shows value, which came from the view model.