bindingtextboxavaloniauicommunity-toolkit-mvvm

Avalonia how to prevent a text box stop updating on every key press?


Avalonia synchronises view and view-model on every key press when using Text Box. This is sometimes quite useful! But I have an application where I'd like the "update" to happen only when I press the enter button or when I loose focus.

Is this possible in Avalonia?


Solution

  • At the time of writing, this is an upcoming feature you can only achieve in v.11.1 Preview. You will set the UpdateSourceTrigger on the binding to LostFocus.

    <TextBox Text="{Binding MyText, UpdateSourceTrigger=LostFocus}" />