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

  • SEARCH
  • Home
  • 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

Related Questions

I'm fairly new to xcode so I apologize if this question is trivial. I'm
I apologies in advance if this question will be trivial or a nonsense...this is
I am pretty new to web work. I apologize if this question is trivial
I am new to the XCode environment so apologies if this sounds trivial. I
Apologies if this is too ignorant a question or has been asked before. A
Apologies if this question is a bit obscure, I've been banging my head against
Apologies if this is a dumb question. In previous ASP.NET projects, I've been using
Apologies if this is a slightly noob question, but looking to clarify my thoughts
Apologies if this was already asked but, I have had a look and can't
I have what is probably a really dumb grep in R question. Apologies, because

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.