Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

mvvm - How to use update source trigger on Wpf Combobox which is editable?

I have a combo box (in my wpf-mvvm app). I have set IsEditable = true. But the "property changed event" is getting fired when I start typing.

How can I set UpdateSourceTrigger = Propertychanged here ?

Also..I need to call a validation function if user has entered new value ( i mean other than those available in list ..using edit functionality).

Any help will be appreciated.

    <ComboBox ItemsSource="{Binding Path = PlanTypeBasedContractNumberList }" Width="90" IsEditable="True"  
SelectedValue="{Binding GeneralCharacteristicsDataContext.ContractNumber.Value}">
                            </ComboBox>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In an editable ComboBox, the SelectedItem and SelectedValue properties refer to the Popup items, not the editable item. Once you start typing, the SelectedItem becomes "unselected" and that's why the event fires.

To bind to the value of the TextBox of the ComboBox, use the Text property:

<ComboBox IsEditable="True" Text="{Binding Path=..., UpdateSourceTrigger=...}">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...