0
votes

I am using combo box that displays numbers starting from 10 to 70. I also want to edit that text and it must get reflected. Hence I have done binding between MyProperty and the combo box Text property. To avoid each character update I have set UpdateSourceTrigger as LostFocus. Now edited text gets reflected after pressing Enter in that. But now selecting item from list, it is not updating and waiting for losing focus. How to overcome this? When edited it should update after losing focus but when item selected from the list it should update instantly.

1
Well it's a little bit hard. There is an option in binding setting updatesourcetrigger to explicit then control it the way you want. But sad part is when you change the text it will trigger selectionchanged event too. And it will keep triggering unless the value typed is out of the range of combobox items.Eldar
yes I have noticed that....but in MS word font size combo box is working as expected...I am expecting same behavior of MS Wordyogapriya shanmugam
Well MS Word is completely different application. Which is not developed with WPF but C++. In WPF you can edit combobox's control template but it's not an easy task to do.Eldar

1 Answers

0
votes

Instead of doing UpdateSourceTrigger=LostFocus you could do something like this:

Text="{Binding MyProperty, Delay=500}"

Using Delay allows you to set a delay before an update occurs. This helps with typing. For my apps, usually 500 milliseconds (1/2 second) works.