✅ Force Binding update in ViewModel where UpdateSourceTrigger==LostFocus
Hi folks - sorry to keep posting, but WPF is proving a difficult mare to break in....
I have a text editor control whose text is bound to a ViewModel Property and
UpdateSourceTrigger
set to LostFocus
It's not possible to set it to PropertyChanged
because it compares the text against a default text set which can be really long. If set to PropertyChanged, it introduces too much lag. Relevant code:
View:
ViewModel:
GistFileViewModel :
The issue is, I have a manual Save button. If I click this, the text control does not seem to loose focus and thus the bound property does not get updated. I'm trying to avoid View code behind as much as possible. The Save button click calls a Command in the ViewModel. How can I go about manually updating either the Property, or forcing the text control to lose focus?
Tried a few bit scraped from the interweb, but no joy.1 Reply
Caved in and did it in the code behind:
Unless anyone can tell me how to do it properly (if 'properly' even is doing eveything in the ViewModel?)