Elisabeth
Elisabeth

Reputation: 21226

Controls in a WPF UserControl don`t raise lost focus

I have a MainWindow with 3 main buttons at the top and below a MainUserControl.

In the MainUserControl I have at top 3 UserControls with ButtonBars and at the bottom a DataGrid.

When I enter data in a DataGridCell and I click into another cell a property change is fired in my ViewModel bound to the DataGrid.

When I enter data... and I click on one of the 3 main buttons again a property change is fired because of Lost Focus event.

When I ... and I click on one of the buttons in the ButtonBar in the UserControl no property change is fired because there seem to be no Lost Focus event.

How can I fix that?

Upvotes: 2

Views: 3202

Answers (2)

Elisabeth
Elisabeth

Reputation: 21226

FocusManager.IsFocusScope="False" on the UserControl or other elements like Menu solved the problem and my property changes are raised now in the model :)

Upvotes: 6

benPearce
benPearce

Reputation: 38383

If you change your binding to to set UpdateSourceTrigger=PropertyChanged then you will not need to rely on the LostFocus to do a property update.

Upvotes: 1

Related Questions