Piero Alberto
Piero Alberto

Reputation: 3943

Mvvm wpf: update value binding before leaving focus of input element

I have this element in my xaml (DevExpress item):

<dxe:ComboBoxEdit IsTextEditable="False" EditValue="{Binding IDTIPOCONN}" 
     ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window},Path=DataContext.ttc}"  />

All the binding are correct, and when I change the value, I trigger some event from my ViewModel.

My problem is the update of the value is executed only when I leave the focus of my comboBox. I need, instead, to execute my action when the value is changed, before leaving its foucs.

How can I do it? I need this because selecting one or another from the list, I show to the user some hidden elements.

Upvotes: 3

Views: 1831

Answers (1)

Anatoliy Nikolaev
Anatoliy Nikolaev

Reputation: 22702

Try for Binding set UpdateSourceTrigger=PropertyChanged:

<dxe:ComboBoxEdit IsTextEditable="False"
                  EditValue="{Binding Path=IDTIPOCONN, UpdateSourceTrigger=PropertyChanged}" ... />

In this case, most likely the default value of UpdateSourceTrigger is LostFocus.

Upvotes: 8

Related Questions