I have a Silverlight application where I have styled my listboxes. This is a part of the style of the ListBoxItem, which is application-wide:
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ListBoxItemGrid" Storyboard.TargetProperty="Background" Duration="0">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MouseOverColorBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
Now I have another listbox where I want nothing to happen when the user hovers over the ListBoxItem. I have tried this:
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver" />
</VisualStateGroup>
But that doesn’t seem to work. How can I override the default, application-wide style? I’m not sure if it is relevant, but the application-wide style is a Style, while my ‘special’ listbox has a Template for its ListBoxItem.
Found it. I had to give the container a style: