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 6667147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:54:09+00:00 2026-05-26T02:54:09+00:00

I have a WPF data trigger that is set to fire when a value

  • 0

I have a WPF data trigger that is set to fire when a value is true.

I want this trigger to fire everytime this value is set to true, even if it was true before. Unfortunately it seems only to fire if the value is changed from true to false or vise versa. My underlying data model is firing the PropertyChanged event of INotifyPropertyChanged even if the value is set to true twice in succession but the Trigger doesn’t seem to pick this up.

Is there anyway to make the trigger run regardless of whether the bound value has changed?

Some of you have asked for the code so here it is. Interesting to note that converters will be called each time. The problem is more specific to running an animation.

Update
If I change my code to reset the value to false and then back to true again it does fire the animation. Obviously this is not ideal and doesn’t make the code nice to read. I’m hoping there is a better way to do this.

Any help greatly appreciated.

WPF code

<Grid>
    <Grid.Resources>            
        <Storyboard x:Key="AnimateCellBlue">
            <ColorAnimation Storyboard.TargetProperty="Background.Color" From="Transparent" To="Blue" Duration="0:0:0.1" AutoReverse="True" RepeatBehavior="1x" />
        </Storyboard>
    </Grid.Resources>
    <TextBox Name="txtBox" Text="{Binding DataContext.DisplayText, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">           
        <TextBox.Style>
            <Style TargetType="TextBox">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DataContext.IsTrue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Value="True">
                        <DataTrigger.EnterActions>                                                        
                            <BeginStoryboard Name="BidSizeUpStoryB" Storyboard="{StaticResource AnimateCellBlue}" />
                        </DataTrigger.EnterActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBox.Style>
    </TextBox>
</Grid>

Code Behind:-

public partial class MainWindow : Window
{
    private DataItem _dataItem;
    private DispatcherTimer _dispatcherTimer;

    public MainWindow()
    {
        InitializeComponent();

        _dataItem = new DataItem();
        _dataItem.DisplayText = "Testing";
        _dataItem.IsTrue = true;

        this.DataContext = _dataItem;

        _dispatcherTimer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, TimerCallbackHandler, Dispatcher);

    }

    private void TimerCallbackHandler(object s, EventArgs args)
    {
        Console.WriteLine("In Timer");
        _dataItem.IsTrue = true;
        _dataItem.DisplayText = "Timer " + DateTime.Now.Ticks;
    }
}

DataItem:-

public class DataItem : INotifyPropertyChanged
{
    private bool _isTrue;
    private string _displayText;

    public bool IsTrue
    {
        get { return _isTrue; }
        set
        {
            _isTrue = value;
            NotifyPropertyChanged("IsTrue");
        }
    }

    public string DisplayText
    {
        get
        {
            return _displayText;
        }
        set 
        { 
            _displayText = value;
            NotifyPropertyChanged("DisplayText");
        }
    }

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;

    #endregion

    private void NotifyPropertyChanged(string info)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(info));
    }
}
  • 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-26T02:54:10+00:00Added an answer on May 26, 2026 at 2:54 am

    The trigger will be fire irrespective of the value set. Whenever PropertyChanged event is raised for the property binded with trigger, the trigger will be get called. Here’s the sample on which i have verified –

    <TextBox>
       <TextBox.Style>
           <Style TargetType="TextBox">
              <Style.Triggers>
                 <DataTrigger Binding="{Binding DataContext.IsTrue, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window},
                                                            Converter={StaticResource MyConverter}}" Value="True">
                      <Setter Property="Background" Value="Red"/>
                 </DataTrigger>
              </Style.Triggers>
           </Style>
       </TextBox.Style>
    </TextBox>
    

    I put the breakpoint on my converter and it got called whenever i raise PropertyChanged event for property IsTrue.
    There msut be some other issue in your code. Can you please show bit of your code where you are facing this issue??

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

Sidebar

Related Questions

I have a set of data that I'd like to present via a WPF
I have a wpf app that needs to communicate(exchange data) with a custom designed
I have a WPF Application using Fluent NHibernate 1.0 RTM and System.Data.SQLite 1.0.65 that
I have a WPF application (.NET 3.0, VS2008) that displays data in a tab
In my WPF app, I have a feedback control that I want to appear
My WPF TabControl contains multiple TabItems. I want to visually alert users that data
I have a situation where I am using wpf data binding and validation using
I have a WPF ListView which repeats the data vertically. I cannot figure out
I have a WPF ListBox bound to a data object. Inside the listbox are
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource

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.