Reputation: 161
I've a combobox like this:
<ComboBox x:Name="CountryMenuComboBox"
ItemsSource="{Binding Countries}">
<ComboBox.ItemContainerStyle>
<Style>
<Setter Property="IsEnabled" Value="{Binding IsRemoving}" />
</Style>
</ComboBox.ItemContainerStyle>
what I need to do is enable or disable the items inside the combobox using the property IsRemoving
, but this property isn't located inside the itemsource Countries
, so I need to access outside the itemsource. How can I do this for a style?
Upvotes: 0
Views: 32
Reputation: 37059
Is IsRemoving
a property of the parent viewmodel that owns the Countries
property? If so, try <Setter Property=“IsEnabled” Value=“{Binding DataContext.IsRemoving, RelativeSource={RelativeSource AncestorType=ComboBox}}” />
Upvotes: 1