Alexey Titov
Alexey Titov

Reputation: 97

WPF MVVM TextBox immidiate bound property update

I have a MVVM app, which shows a TextBox with its text bound to a viewmodel property:

    Text="{Binding Path=Caption, Mode=TwoWay}

The update of 'Caption' property happens only when putting cursor to any other control. Is there a way, a good way, to have the 'Caption' property updated immediately when typing any char? I need this because my app displays a view twice, in same window - one is real 'work area', another - a 'thumbnail', in a listbox of all loaded 'work areas'. 'Work area' would show the new text correctly. A 'thumbnail' updates the textbox only when it loses cursor

Upvotes: 1

Views: 191

Answers (1)

Lorentz Vedeler
Lorentz Vedeler

Reputation: 5301

For the text property, the default way to update bindings is LostFocus not PropertyChanged, you need to set this explicitly.

Text="{Binding Path=Caption, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}

Source

Upvotes: 4

Related Questions