WPF RaisePropertyChanged event on lost focus

后端 未结 2 1436
日久生厌
日久生厌 2021-01-05 15:51

I have a C# WPF MVVM application that works fine.

The only problem is when I modify a textbox and click on the menu. If I do that without clicking on another control

2条回答
  •  花落未央
    2021-01-05 16:32

    This is a common gotcha with TextBoxes in both WPF and WinForms. You can get around this by instructing the binding system to update the VM with every change to the TextBox instead of when it loses focus. To do this, set the UpdateSourceTrigger of the binding to PropertyChanged. This will write back to the VM any time the TextBox raises the PropertyChanged event for its Text property.

    
    

提交回复
热议问题