WPF listview databinding - How to force update base object without tabs?

I have a WPF ListView associated with a BindingList <T>. Binding works like a charm, but I have to pop out of the cell to get the related property to update .... this is a problem because most users do not go beyond the last column before clicking the save button.

How to make a list view “save” changes to the associated DataContext without doing something hacky.

+5
source share
1 answer

Bindings in WPF have the " UpdateSourceTrigger " property , which tells Binding when the item that the user interface is associated with is updated. By default, it is set to "LostFocus" for the Text property, which you most likely use.

Change the trigger to "PropertyChanged" in your binding, for example:

Text="{Binding Foo,UpdateSourceTrigger=PropertyChanged}"

... and now the original "Foo" property will be updated as the text in the user interface changes.

There is also an Explicit parameter for UpdateSourceTrigger, which is convenient if you need to pause writing any changes to the source until, say, the user clicks the OK button.

+11
source

All Articles