Hi Community,
I've created a ControlTemplate in my
Application.Resources.
I'm using this Template for Buttons to make their Background transparent.
<ControlTemplate TargetType="Button" x:Key="HollowButtonTemplate">
<Border x:Name="bord" Background="#00000000">
<ContentPresenter Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers[...]>
</ControlTemplate>
There are two Triggers.
One to make a hover-effect and another to make my button glowing.
Hover-Effect
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Direction="255" BlurRadius="3"
ShadowDepth="1" Color="Black"/>
</Setter.Value>
</Setter>
</Trigger>
Glow-Effect
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard Storyboard="{StaticResource HollowButtonGlow}"/>
</EventTrigger>
<Storyboard x:Key="HollowButtonGlow">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Effect).Color">
<SplineColorKeyFrame KeyTime="0:0:0.0" Value="White" />
<SplineColorKeyFrame KeyTime="0:0:0.4" Value="Black" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
Now Adding the Template to my Button
<Button x:Name="btHollow" Template="{StaticResource HollowButtonTemplate}">
HollowButtonContent
</Button>
And it works fine :)
But if i put some code in my ClickEvent-Handler ...
<Button x:Name="btHollow" Click="btHollow_Click" Template="{StaticResource HollowButtonTemplate}">
HollowButtonContent
</Button>
private void btHollow_Click(object sender, RoutedEventArgs e)
{
}
...the animation starts after the code is finished :(
Is there a common way to make a click-Animation without using a seperate Thread for the ClickEvent-Handler-Code ?