Skip to content

Instantly share code, notes, and snippets.

@ichengzi
Created November 5, 2016 12:06
Show Gist options
  • Save ichengzi/fb24e3f462a7b0d248d5e85afb46dfac to your computer and use it in GitHub Desktop.
Save ichengzi/fb24e3f462a7b0d248d5e85afb46dfac to your computer and use it in GitHub Desktop.
wpf triggers(property,data,event)
<TextBlock Text="Hello">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Blue"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red" />
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Text}" Value="Hello">
<!--<Setter Property="Text" Value="Yes!" />-->
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.300" Storyboard.TargetProperty="FontSize" To="28" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.800" Storyboard.TargetProperty="FontSize" To="18" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment