[英]WPF combobox set selected item on lost focus
I have: 我有:
<Combobox ItemsSouce="{Binding SomeCollection}" SelectedItem="{Binding SomeItem}" />
My property SomeItem
looks like: 我的财产
SomeItem
看起来像:
public object SomeItem
{
get
{
return _someItem;
}
set
{
LogMessage("SomeItem has changed to" + value);
_someItem = value;
OnPropertyChanged("SomeItem");
}
}
How can I prevent calling the set method when the user scrolls through the combobox? 当用户滚动组合框时,如何防止调用set方法? I want to call that set method when the combobox loses focus.
当组合框失去焦点时,我想调用该set方法。
尝试将updatesource触发器设置为在绑定中失去焦点。
<Combobox ItemsSouce="{Binding SomeCollection}" SelectedItem="{Binding SomeItem, UpdateSourceTrigger=LostFocus}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.