Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 527927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:56:04+00:00 2026-05-13T08:56:04+00:00

Apologies for this trivial question, I’m new to WPF and keep finding blogs that

  • 0

Apologies for this trivial question, I’m new to WPF and keep finding blogs that almost describe what I want…

I have a Label that is bound to a property and updating nicely on screen, and now I’d like a small animation that flashes the background colour of the label whenever the value is updated. Ideally I’d like a pure xaml solution

I’ve looked at DataTriggers but they seem to require an equality condition to hold, and EventTriggers seem to not be possible to attached to any events to do with the display of data

thanks
Oskar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:56:04+00:00Added an answer on May 13, 2026 at 8:56 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 253k
  • Answers 253k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to put the value in the column id… May 13, 2026 at 9:54 am
  • Editorial Team
    Editorial Team added an answer Post-increment usually involves keeping a copy of the previous value… May 13, 2026 at 9:54 am
  • Editorial Team
    Editorial Team added an answer It takes a compile-time type, like so: ValueRange<int> range; It's… May 13, 2026 at 9:54 am

Related Questions

I am relatively new to PHP, so my apologies if the answer is trivial.
My work requires that I perform a mathematical simulation whose parameters come from a
I apologize is this is a duplicate and I just could not phrase the
First off let me apologize to the SO community for coming to you with
First of all, apologies for the subjective sounding title. This is intended as a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.