please check if code below would work for you. Any change for Content property of the label is animated. It's done using triggers and value converter class which does the small trick converting content value to either "True" or "False" and triggers are set up to react on those 2 values. Cnverter is attached to the Tag property of the label which is bent to the Name property of data context. Also I've added some animation to mouse enter and leave events which are pretty straightforward and done only using RouterEvents in xaml.
converter:
public class TestConverter : IValueConverter
{
private string _originalValue = String.Empty;
private bool _previousValue = false;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
_originalValue = (string)value;
_previousValue = !_previousValue;
return _previousValue.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return _originalValue;
}
}
data context initialization:
label1.DataContext = new Test() { Name = DateTime.Now.ToString() };
xaml:
<Window.Resources>
<local:TestConverter x:Key="TestConverter" />
</Window.Resources>
<Grid>
<Label
Height="28"
HorizontalAlignment="Left"
Margin="132,96,0,0"
Name="label1" VerticalAlignment="Top" Width="120">
<Label.Content>
<Binding Path="Name"/>
</Label.Content>
<Label.Tag>
<Binding Path="Name" Converter="{StaticResource TestConverter}"/>
</Label.Tag>
<Label.Background>
<SolidColorBrush x:Name="animatedBrush1" Color="Yellow" />
</Label.Background>
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<Trigger Property="Tag" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard AutoReverse="True">
<!--<DoubleAnimation
Storyboard.TargetProperty="FontSize" To="20"/>-->
<DoubleAnimation
Storyboard.TargetProperty="Opacity" To="0.0" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
<Trigger Property="Tag" Value="False">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard AutoReverse="True">
<DoubleAnimation
Storyboard.TargetProperty="FontSize" To="20"/>
<!--"<DoubleAnimation
Storyboard.TargetProperty="Opacity" To="0.0" AutoReverse="True"/>-->
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</Label.Style>
<Label.Triggers>
<EventTrigger RoutedEvent="Label.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="animatedBrush1"
Storyboard.TargetProperty="Color"
To="Blue" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Label.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="animatedBrush1"
Storyboard.TargetProperty="Color"
To="Yellow" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Label.Triggers>
</Label>
</Grid>
hope this helps, regards