Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine DataTrigger and Trigger in a MultiDataTrigger

I've seen from some examples that it is possible to combine this kind of trigger:

<Trigger Property="IsMouseOver" Value="True">

With this kind of data trigger :

<DataTrigger Binding="{Binding IsHighlightable}" Value="True" />

By using a MultiDataTrigger like this:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True"/>
        <Condition Binding="{Binding IsHighlightable}" Value="True" />
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.Setters>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="#BF6DBDD1"/>
        <Setter Property="Background" Value="{StaticResource SelectedItemBackgroundBrush}"/>
    </MultiDataTrigger.Setters>
</MultiDataTrigger>

However, this does not work with attached properties. This trigger works:

<Trigger Property="UI:TreeViewHelper.IsMouseDirectlyOverItem" Value="True">

But this does not work:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=UI:TreeViewHelper.IsMouseDirectlyOverItem}" Value="True"/>
        <Condition Binding="{Binding IsHighlightable}" Value="True" />
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.Setters>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="#BF6DBDD1"/>
        <Setter Property="Background" Value="{StaticResource SelectedItemBackgroundBrush}"/>
    </MultiDataTrigger.Setters>
</MultiDataTrigger>

Is there a way I could make the trigger work correctly inside the MultiDataTrigger? The IsMouseDirectlyOverItem property was taken from here http://blogs.msdn.com/b/mikehillberg/archive/2006/09/21/mytreeviewhelperismousedirectlyoveritem.aspx.

Thanks

like image 538
Carl Avatar asked Jul 10 '12 18:07

Carl


2 Answers

The syntax for attached properties is different:

Path=(UI:TreeViewHelper.IsMouseDirectlyOverItem)
like image 130
H.B. Avatar answered Nov 16 '22 23:11

H.B.


<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding IsHighlightable}" Value="True"/>
        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True"/>
    </MultiDataTrigger.Conditions>
    <MultiDataTrigger.Setters>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="#BF6DBDD1"/>
        <Setter Property="Background" Value="{StaticResource SelectedItemBackgroundBrush}"/>
    </MultiDataTrigger.Setters>
</MultiDataTrigger>
like image 6
B.Balamanigandan Avatar answered Nov 16 '22 22:11

B.Balamanigandan