Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataGrid , TextBox - binding and instant updates

My app. contains the window in the picture:

alt text

The ItemsSource of the DataGrid is set to _editList ( declared as IList < Vendor > _editList;).

The data grid is set to Read Only.

The Vendor Name text box has the binding set as : Text="{Binding ElementName=dataGridVendors, Path=SelectedItem.Name, Mode=TwoWay}"

This works well. However, as it is the Vendor Name cell only updates when the user is done typing in the Vendor Name textbox and clicks on something else. Say I want to change the vendor name to "John Lennon II" . I have to click on the textbox and type the characters I want to add and than I have to click on something else and only then the datagrid makes the update.

I want to make the update happen as the user types the characters....Is this possible ?

Regards, Sebastian

like image 799
MadSeb Avatar asked Oct 10 '10 19:10

MadSeb


1 Answers

Add the UpdateSourceTrigger to your Binding

Text="{Binding ElementName=dataGridVendors, Path=SelectedItem.Name, Mode=TwoWay,  UpdateSourceTrigger=PropertyChanged}"

Its default trigger is lost focus. When you change it to PropertyChanged the Updates will done when you're typing.

like image 84
Mark Avatar answered Nov 17 '22 01:11

Mark