wpf - Binding with UpdateSourceTrigger==LostFocus do not fire for Menu or Toolbar interaction -
i noticed bindings updatesourcetrigger==lostfocus not updated when user activates menu or toolbar.
this leads unfortunate situation last change user made gets lost when user selects "save file" menu or toolbar.
is there easy way around or have change bindings updatesourcetrigger=propertychanged.
the problem textbox does, in fact, not lose focus when menu item activated. thus, updatesourcetrigger lostfocus not fire. depending on (view)model, updatesourcetrigger propertychanged might or might not feasible workaround.
for me, propertychanged not option (i need validate data after user finished entering it, not in between), used workaround calling method before "save file" (or other menu/toolbar entry requires up-to-date model):
public shared sub savefocusedtextbox() dim focusedtextbox = trycast(keyboard.focusedelement, textbox) if focusedtextbox isnot nothing dim = focusedtextbox.getbindingexpression(textbox.textproperty) if isnot nothing be.updatesource() end if end sub a few other approaches problem can found in related question:
(in fact, credit method goes rudigrobler's answer in question.)
Comments
Post a Comment