I have an appication-level style for ComboBoxItem
:
<Style TargetType="{x:Type ComboBoxItem}" x:Key="DefaultComboBoxItemStyle">
<!-- ... -->
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<!-- ... -->
</Style>
<Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource DefaultComboBoxItemStyle}" />
This style is suitable for me in 99% cases. But, there's 1%, when bound objects haven't IsSelected
property. I want to override this binding (in particular, clear it at all).
I thought, that this will be possible this way:
<!-- somewhere in application code -->
<ComboBox Margin="5" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource DefaultComboBoxItemStyle}">
<Setter Property="IsSelected" Value="False"/>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
But it doesn't work, binding errors still present. Is there any way to achieve what I want in XAML?