[英]Binding style property outside itemsource?
我有一个这样的组合框:
<ComboBox x:Name="CountryMenuComboBox"
ItemsSource="{Binding Countries}">
<ComboBox.ItemContainerStyle>
<Style>
<Setter Property="IsEnabled" Value="{Binding IsRemoving}" />
</Style>
</ComboBox.ItemContainerStyle>
我需要做的是使用属性IsRemoving
启用或禁用组合IsRemoving
,但是此属性不在itemsource Countries
,因此我需要在itemsource外部进行访问。 我该如何做一个风格?
被IsRemoving
拥有该父视图模型的财产Countries
的财产? 如果是这样,请尝试<Setter Property=“IsEnabled” Value=“{Binding DataContext.IsRemoving, RelativeSource={RelativeSource AncestorType=ComboBox}}” />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.