禁用组合框的下拉菜单功能 [英] Disableing Dropdown Feature of Combo Box

查看:99
本文介绍了禁用组合框的下拉菜单功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个组合框,使用列表作为ItemSource.列表的第一项直接显示在组合"框中.我想要的是:
如果项目多于1个,则应启用下拉菜单(自动工作),但是如果列表中只有一项,我想在组合框中显示该项目并禁用Dropdown!
有可能在xaml中执行此操作吗? (是时尚还是时尚?)

亲切的问候
moti

Hi,
I have a Combo Box, using a List as ItemSource. The First Item of the List is displayed directly in the Combo box. What i want is:
If there are more than 1 items, dropdown should be enabled (works automatically), but if there is just one item in the List, i want to display it in the combo box and disable Dropdown!
is there any possibility to do this in xaml? (Style or somthing?)

Kind Regards
moti

推荐答案

这真的很简单.

下拉菜单的Define和IsEditable属性.
将下拉菜单的Editable属性绑定到此属性.

如果您的收藏集只有一行,请通过设置属性禁用下拉菜单.
当然,您需要实现INOtifyPropertyChanged.
This is really quite simple.

Define and IsEditable property for the dropdown.
Bind the Editable property of the dropdown to this property.

If your collection has just one row disable the dropdown by setting the property.
You need to have INOtifyPropertyChanged implemented, of course.


我找到了另一种方法来实现这一目标...
设置
IsHitTestVisible = False;
IsEditable = False;
Focusable = False;

正是我想要的!
我使用DataTrigger在xaml中制作了样式,检查列表的Count属性,然后设置属性,如上所示.

向Moti致意
i found another way to achiev this...
set
IsHitTestVisible = False;
IsEditable = False;
Focusable = False;

did exactly what i want!
I made a Style in xaml with a DataTrigger, checking the Count Property of my List, and set the Properties as shown above.

Greets Moti


这篇关于禁用组合框的下拉菜单功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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