如何在可编辑的 Wpf Combobox 上使用更新源触发器? [英] How to use update source trigger on Wpf Combobox which is editable?

查看:46
本文介绍了如何在可编辑的 Wpf Combobox 上使用更新源触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框(在我的 wpf-mvvm 应用程序中).我已经设置了 IsEditable = true.但是当我开始打字时,属性更改事件"被触发.

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.

如何在此处设置 UpdateSourceTrigger = Propertychanged ?

另外..如果用户输入了新值,我需要调用一个验证函数(我的意思是除了列表中可用的值之外..使用编辑功能).

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).

任何帮助将不胜感激.

    <ComboBox ItemsSource="{Binding Path = PlanTypeBasedContractNumberList }" Width="90" IsEditable="True"  
SelectedValue="{Binding GeneralCharacteristicsDataContext.ContractNumber.Value}">
                            </ComboBox>

推荐答案

在可编辑的 ComboBox 中,SelectedItemSelectedValue 属性是指Popup 项目,而不是可编辑项目.一旦你开始输入,SelectedItem 就会变成unselected",这就是事件触发的原因.

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.

要绑定到 ComboBoxTextBox 的值,请使用 Text 属性:

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

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

这篇关于如何在可编辑的 Wpf Combobox 上使用更新源触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆