1

I want to have a MultiDataTrigger for my TabControl. When the tab is hovered it should change the color. But not if the Tab is selected. I tried a MultiDataTrigger. But it does not seem to work. Here is my Style:

<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabItem}">
            <Grid>
                <Border Name="Border" BorderBrush="Black" BorderThickness="0.5,0.5,0.5,0" CornerRadius="4,4,0,0">
                    <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="12,2,12,2"/>
                </Border>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter TargetName="Border" Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#fefeff" Offset="0" />
                                <GradientStop Color="#e7edf6" Offset="1" />
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsSelected" Value="False">
                    <Setter TargetName="Border" Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#c5d0df" Offset="0" />
                                <GradientStop Color="#aab4c2" Offset="1" />
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=IsMouseOver}" Value="True" />
                        <Condition Binding="{Binding Path=IsSelected}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter TargetName="Border" Property="Background">
                        <Setter.Value>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#dde6f2" Offset="0" />
                                <GradientStop Color="#c6d0de" Offset="1" />
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </MultiDataTrigger>

            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Setter.Value>
</Setter>

Is there something wrong?

2 Answers 2

4

Change your trigger to be:

<MultiTrigger.Conditions>
    <Condition Property="IsSelected" Value="false"/>
    <Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>

As per AngelWPF's answer a DataTrigger will attempt to bind to the current DataContext, where it will find nothing matching the properties.

1
  • @Anonymous you're using MultiDataTriggers, not MultiTriggers Oct 25, 2011 at 9:46
2

DataTriggers use the DataContext as the source. And I am sure that IsMouseOver and IsSelected are not properties from your data context, they are properties of the tab item.

I suggest use normal MultiTrigger with normal Trigger Conditions in it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.