简体   繁体   中英

WPF - Trigger "LostFocus" on currently active element in Tab before Tab Change

I have a TabControl, and each TabItem has multiple, data-bound textboxes. When I edit an text in one box, and the switch the tab directly (without leaving the textbox), the change is lost. Apparently, the "LostFocus" Event is not triggered when changing the tab, so the new value is not written to the bound property.

How can I trigger the "LostFocus" on the currently active (or all) elements in the active tab before changing over to the new tab?

I could surely do an override and call the event manually on all elements, but that would be quite unhandy because one has to update that list every time a field is added.

Is there some way to do it automatically?

使用UpdateSourceTrigger.PropertyChanged而不是LostFocus并将绑定Delay属性设置为您选择的间隔。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM