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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:48:55+00:00 2026-06-17T21:48:55+00:00

For a WPF TextBlock, setting the TextTrimming to TextTrimming.CharacterEllipsis will cause it to automatically

  • 0

For a WPF TextBlock, setting the TextTrimming to TextTrimming.CharacterEllipsis will cause it to automatically cut off the text before it overflows and add some ellipses to the end. This article shows how to check if the text is being trimmed and automatically show the full text in a tooltip when it is.

It does this, without subclassing TextBlock, by registering an event handler that listens to the SizeChanged event:

EventManager.RegisterClassHandler(
    typeof( TextBlock ),
    FrameworkElement.SizeChangedEvent,
    new SizeChangedEventHandler( OnTextBlockSizeChanged ),
    true );

The trouble is, this only reacts to size changed events – it works fine if the text overflows because you shrank the control, but not if it overflows because you changed the text.

Unfortunately, although the TextBlock does have a SizeChangedEvent, it doesn’t have a TextChangedEvent. I thought of listening to the TargetUpdated event:

EventManager.RegisterClassHandler(
    typeof(TextBlock),
    Binding.TargetUpdatedEvent,
    new EventHandler<DataTransferEventArgs>(OnTextBlockTextChanged),
    true);

But that didn’t have any discernable effect, even with the NotifyOnTargetUpdated property set to true. I also tried overriding the metadata on the TextProperty but it seems that can really only be done in its static constructor – in this case the TextBlock’s static constructor. Is there any way of achieving this without subclassing TextBlock?

  • 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-06-17T21:48:56+00:00Added an answer on June 17, 2026 at 9:48 pm

    You can use DependencyPropertyDescriptor:

    var descriptor = DependencyPropertyDescriptor.FromProperty(TextBlock.TextProperty, typeof(TextBlock));
    descriptor.AddValueChanged(...);
    

    PS. Why on Earth TextBlock does not have an IsTrimmed property is beyond me.

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

Sidebar

Related Questions

How to add a TextBlock to an Ellipse in WPF/Silverlight?
In WPF, is there any way to have the Text property of a TextBlock
I have a textblock in a grid in WPF. I want the text to
Is it possible in WPF to spend HTML text in a TextBlock? All formatting
I know TextBox/TextBlock already support text word wrap very well. (Windows WPF) the question
I'm presenting text in a wpf TextBlock control (.Net 3.5). The content of the
How can I bind a WPF TextBlock to a text file? I want for
I my WPF application I'd like to change the text color by setting Foreground
I'm trying to assign some SystemColor foreground to a TextBlock on XAML for WPF.
I need to apply some text formatting when displaying items in a WPF ListView.

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.