Click here to Skip to main content
15,745,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

Actually the title contains all the question. I have a TextBlock control on my my page, I would like to monitor it's Text property to fire an event whenever it is changed. If anybody can suggest a solution, please do.
Thank you in advance!

Best Regards,

Dear Parwej Ahamad,
Thank you for your quick response. But my requirements are really different. So the reason is - that I want to implement a behavior for TextBlock control, which animates the text symbol by symbol when it changes. So in this case, whenever I need the animation, I just want to add the behavior to the TextBlock without modifying the code behind. And whenever I remove the behavior, the text will not be animated any more, and I don't need to modify the code again. This is my only reason.
Updated 19-Feb-10 8:00am

As per my understanding why you don't target change event of source control? Let me explain:

TextBlock is not an input control so there supposed to be you are binding TextBlock control with TextBox and end user entering the text or you are setting TextBox value from some other source. So Just you can trap the TextBox TextChanged event and in code behind you can perform as your requirement.

Please let me know if your requirement is different.
Share this answer
Actually... I found the answer in the Expression forum... I would share it with those who are interested in... Somebody suggested to bind the Text property to my own DependencyProperty, which has an event trigger. That is what I am going to do now. I am going to Select the 1st answer as the solution, because I cannot choose my own, but note for readers... Here is the main idea ;)

Best Regads,
Share this answer
You are exactly right. You have to chose using the DependencyProperty binded with the TextBlock. Remember that, if you want to bind data you must have to use DependencyProperty instead of normal CLR Property.

If you need any help on DependencyProperty visit my blog post here:[^]

All the best... :thumbsup:
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900