I needed a TextBlock control with a more pessimistic text trimming mechanism. None of the TextTrimming options were working for me, so I decided to subclass TextBlock and detect when the size or the text was changed. Then I could adjust the text as needed.
TextBlock exposes a SizeChanged event so that was easy.
AddHandler Me.SizeChanged,
AddressOf me_SizeChanged
AddHandler Me.TextChanged,
AddressOf me_TextChanged
Private dpText As DependencyPropertyDescriptor
dpText =
DependencyPropertyDescriptor.FromProperty(TextBlock.TextProperty, GetType(TextBlock))
dpText.AddValueChanged(Me, AddressOf me_TextChanged)
No comments:
Post a Comment