我想绑定到SelectedItems.Count
从DataTemplate
位于ResourceDictionary
. 当计数达到一定数量时,我想启用/禁用一个按钮ListBoxItems
。我认为这会起作用:
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding Source={StaticResource myResourceKey}, Path=myListBox.SelectedItems.Count}" Value="25">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
但我收到以下错误:
System.Windows.Data Error: 40 : BindingExpression path error: 'myListBox' property not found on 'object' ''DataTemplate' (HashCode=50217655)'. BindingExpression:Path=aoiListBox.SelectedItems.Count; DataItem='DataTemplate' (HashCode=50217655); target element is 'Button' (Name='myBtn'); target property is 'NoTarget' (type 'Object')
我怎样才能实现这种绑定?提前致谢。