Wpf 绑定ListBoxItem';已设置ItemTemplate的IsEnabled属性
我有以下列表框:Wpf 绑定ListBoxItem';已设置ItemTemplate的IsEnabled属性,wpf,xaml,data-binding,windows-phone-7,Wpf,Xaml,Data Binding,Windows Phone 7,我有以下列表框: <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" SelectionChanged="ListBoxContainerSelectionChanged" ItemsSource="{Binding
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
SelectionChanged="ListBoxContainerSelectionChanged"
ItemsSource="{Binding Movies}"
ItemContainerStyle="{StaticResource HeaderListBoxItemStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<Controls:MoviesItemControl Header="{Binding Title}"
Detail="{Binding FormattedDescription}"
Rating="{Binding Rating}"
Opacity="{Binding IsSuppressed, Converter={StaticResource DimIfTrueConverter}}"
IsEnabled="{Binding IsSuppressed, Converter={StaticResource InverseBooleanConverter}}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我正在尝试设置被“抑制”(未找到描述的电影)的ListBoxItem
s的禁用状态。我有一个属性,我可以绑定到我的单个控件,但我希望它们在实际列表中不可选择。(并使用myItemsContainerStyle
中包含的禁用状态)
我见过一些使用触发器的实现,但在WP7中似乎不可用,我更希望不必为每个控件创建不同的样式,以便它们正确绑定
有什么想法吗 请参见以下问题:
这反过来又链接到:
我为这个特定场景试用了SetterValueBindingHelper
by,效果非常好。您只需将SetterValueBindingHelper.cs添加到项目中,然后就可以像这样在setter中绑定IsEnabled
<Style x:Key="HeaderListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="delay:SetterValueBindingHelper.PropertyBinding">
<Setter.Value>
<delay:SetterValueBindingHelper Property="IsEnabled"
Binding="{Binding IsSuppressed}"/>
</Setter.Value>
</Setter>
</Style>
谢谢!我专门为此列表制作了一个新的样式
,因为并非我所有的型号
都有此IsSuppressed
标志,但我想要相同的交互。有没有一种方法可以在不向每个模型添加该属性的情况下,仅使用1样式
?