如何禁用组合框项目? [英] How to Disable Combobox Items?

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

问题描述

有一种方法可以通过索引访问其项目的属性来禁用WPF ComboBox的前x个项目。

Is there a way to disable all but the first x items of a WPF ComboBox by accessing its items' properties via an Index?

编辑:

 ComboBoxItem DiffieHellmanItem = (ComboBoxItem)comboboxName.ItemContainerGenerator.ContainerFromIndex(i));

工作

推荐答案

编辑:
看起来你找到了一个方法来获取ComboBoxItems。你可能还想看看ItemContainerStyle,看看是否有一些DataBinding可以利用(如果你的项目有一个Enabled属性或类似的东西)。

Looks like you found a way to get at the ComboBoxItems. You might also want to look at ItemContainerStyle and see if there's some DataBinding you can take advantage of (if your items have an Enabled property or something similar).

关于你如何做你的DataBinding,你可以通过使用DataTemplates在不同的画笔,不透明度等显示你的禁用项目。 Bea Stollnitz有一篇关于此处的好帖子。

However, depending on how you are doing your DataBinding, you may be able to display your "disabled" items in a different Brush, Opacity, etc. by using DataTemplates. Bea Stollnitz has a good post about that here.

从UX的角度来看,你可能想要考虑的一个原因是为什么要让它们被禁用而不是隐藏。是否有某种渐进式的披露策略,你可以利用没有一个ComboBox填充用户不能点击的东西。

One thing you might want to consider from a UX standpoint is why you want to make them disabled as opposed to hidden. Is there some sort of progressive disclosure tactic that you can take advantage of to not have a ComboBox filled with things the user can't click?

这篇关于如何禁用组合框项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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