I have a Button
ControlTemplate
and I'm trying to modify a DropShadowEffect
on a Border
by using a Trigger
. Here is my Xaml:
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="ButtonBorder" Margin="10" CornerRadius="5" Background="Gray">
<Border.Effect>
<DropShadowEffect ShadowDepth="5" x:Name="BorderEffect" />
</Border.Effect>
<ContentPresenter HorizontalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="Background" TargetName="ButtonBorder" Value="LightGray" />
</Trigger>
<Trigger Property="Button.IsPressed" Value="True">
<Setter Property="Margin" TargetName="ButtonBorder" Value="13,13,7,7" />
<!-- this is where I get the error -->
<Setter Property="ShadowDepth" TargetName="BorderEffect" Value="2" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
I get on error stating that the BorderEffect cannot be found.
I have also tried:
<Setter Property="Effect.ShadowDepth" TargetName="ButtonBorder" Value="2" />
But I also get an error telling me that the property ShadowDepth
could not be found on the object of type Effect
(because it's using the base class instead of DropShadowEffect
)
How can I solve this?