【发布时间】:2010-12-25 11:58:51
【问题描述】:
我有一个 ListBox 模板。在 ListBox 中,我在 ListBoxItems 上有一个模板。我想禁用其中的一些项目(我仍在研究我想用什么来触发“事件”,所以我现在只输入了 IsSelected)
我的问题是我需要获取 ListBoxItem 的一些数据以了解它是否应该被禁用(即,我们现在正在查看哪一个...)
我以为我会使用 ConverterProperty,但它似乎只允许资源和硬编码值(我无法在没有反射的情况下进行数据绑定,我不想这样做)。
我尝试传入RelativeSource Self 和ConverterParameter,而那只是传入了一个不会转换为ListBoxItem 的RelativeSource 类型的对象。
有什么想法吗?
<Style x:Key="CheckBoxListStyle" TargetType="ListBox">
<Style.Resources>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected,
RelativeSource={RelativeSource Self},
Converter={StaticResource DisableWorkItemConverter},
ConverterParameter={RelativeSource Self}}" Value="True">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
【问题讨论】:
标签: wpf data-binding resources binding