WPF Trigger / Style overrides another

Posted by ozczecho on Stack Overflow See other posts from Stack Overflow or by ozczecho
Published on 2010-05-18T05:19:10Z Indexed on 2010/05/18 5:20 UTC
Read the original article Hit count: 352

Filed under:
|
|
|
|

I have a listview defined as such

                            <ListView Width="auto" 
                              SelectionMode="Single"
                              ItemContainerStyle="{StaticResource baseListViewStyle}"
                               .... 

Then in "baseListViewStyle" I have defined some base styles to apply to my list views, including a Style trigger:

<Style x:Key="baseListViewStyle" TargetType="ListViewItem">
    <Setter Property="Height" Value="20" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Foreground" Value="Red" />
        </Trigger>
    </Style.Triggers>
</Style>

The trigger here highlights the row when mouse is over it. Nice.

I also have a Data Trigger on the listviewitem:

                <Style.Triggers>
                <DataTrigger Binding="{Binding IsTestTrue}" Value="True">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource SomeFunkyAnimation}" />
                    </DataTrigger.EnterActions>
                </DataTrigger>

If test is true then a nice little fade animation is played out. This all works except when I move my mouse over the row where "test is true" the animation stops and the mouse over style is displayed.

Any ideas how I can override that style in my DataTrigger?

TIA

© Stack Overflow or respective owner

Related posts about wpf

Related posts about style