Reputation: 7307
I come from a web background, so I'm really struggling with this one.
I have a style that I need applied when both IsMouseOver is true and a class variable (called _isLinking) is true within my Linking class is true also. I have the style built and functioning with the IsMouseOver, but I'm not sure how to get the second condition with the _isLinking in there.
<Path.Style>
<Style>
<Setter Property="Path.Stroke" Value="Black" />
<Setter Property="Path.Fill" Value="LightGray" />
<Style.Triggers>
<Trigger Property="Canvas.IsMouseOver" Value="True">
<Setter Property="Path.Stroke" Value="Blue" />
<Setter Property="Path.Fill" Value="LightBlue" />
</Trigger>
</Style.Triggers>
</Style>
</Path.Style>
Upvotes: 0
Views: 77
Reputation: 19296
You should use MultiDataTrigger
(msdn).
Example:
<Canvas>
<Path>
<Path.Data>
<PathGeometry Figures="M 10,100 C 10,300 300,-200 300,100" />
</Path.Data>
<Path.Style>
<Style>
<Setter Property="Path.Stroke" Value="Black" />
<Setter Property="Path.Fill" Value="LightGray" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Canvas}}" Value="True" />
<Condition Binding="{Binding IsLinking}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Path.Stroke" Value="Blue" />
<Setter Property="Path.Fill" Value="LightBlue" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Canvas>
In the above example DataContext
is set to object of type Linking
.
this.DataContext = new Linking { IsLinking = true };
Upvotes: 2