禁用列表框中的特定项目 [英] Disable particular item in the ListBox
本文介绍了禁用列表框中的特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将对象列表绑定到 WindowsPhone 应用程序中的 ListBox.此业务对象具有一个布尔属性.基于布尔属性,我需要在 ListBoxItem 中设置 IsEnabled 属性.
I bind list of objects to my ListBox in WindowsPhone application. This business object has one boolean property. Based on the Boolean property i need to set the IsEnabled property in the ListBoxItem.
有没有办法在 WindowsPhone ListBox 中实现这一点?
Is there any way to achieve this in WindowsPhone ListBox ?
推荐答案
有几种方法可以实现:
- 您可以通过 C# 代码添加 ListBoxItem 并正确设置属性.
- 在 Xaml 的列表框中,放置以下内容:
<Setter Property="IsEnabled" Value="{Binding Content.IsEnabled, RelativeSource={RelativeSource Self}}"/>
</Style>
这里假设你的模型对象中的属性名称是IsEnabled,根据真实名称修改.
Here I assume that the property name in your model object is IsEnabled, change it according to its real name.
这篇关于禁用列表框中的特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文