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

查看:626
本文介绍了如何使用更新源触发器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 SelectedItem SelectedValue 属性引用 Popup 项目,而不是可编辑项目。一旦你开始键入, SelectedItem 变成未选择,这就是事件触发的原因。

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.

ComboBox TextBox ,使用 Text 属性:

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

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

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