Reputation: 17196
I'd like to use a trigger outside a style. Edit: whoops, sorry, it's actually inside a style for MainWindow, but I want the trigger to apply to the Ellipse and not MainWindow.
<Ellipse Fill="White" StrokeThickness="1" Stroke="Black">
<Ellipse.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="Yellow"/>
</Trigger>
</Ellipse.Triggers>
</Ellipse>
How do I fix the compiler error, which is "Cannot find the static member 'FillProperty' on the type 'MainWindow'"?
Upvotes: 3
Views: 1692
Reputation: 21873
you have to put this in style
<Ellipse StrokeThickness="1" Width="20" Height="20" Stroke="black">
<Ellipse.Style>
<Style TargetType="{x:Type Ellipse}">
<Setter Property="Fill" Value="Red"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Fill" Value="green"/>
</Trigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
Upvotes: 4
Reputation: 185300
In direct Triggers you need qualifying type names like so:
<Ellipse Width="100" Height="100">
<Ellipse.Triggers>
<Trigger Property="Ellipse.IsMouseOver" Value="True">
<Setter Property="Ellipse.Fill" Value="Yellow" />
</Trigger>
</Ellipse.Triggers>
</Ellipse>
This won't work though since direct triggers only allow EventTriggers
, use a Style instead.
Upvotes: 2
Reputation: 2152
Your window doesn't have a property named "Fill" like an Ellipse does. Maybe you mean "Background".
Upvotes: 0