2
I’ve seen the property of TextBlock
does not have an event when changing text. Is there any way to do an event when the text is changed?
* Remembering that it is for WPF and not Windows Forms. This question is only for WPF.
2
I’ve seen the property of TextBlock
does not have an event when changing text. Is there any way to do an event when the text is changed?
* Remembering that it is for WPF and not Windows Forms. This question is only for WPF.
2
Use a Binding for the property Text
and seven in the DataContext
of the screen. From there you can use the NotifyOnTargetUpdated
and the TargetUpdated
, thus:
<TextBlock Name="textBlock1" Text="{Binding MeuTexto, NotifyOnTargetUpdated=True}"
TargetUpdated="textBlock1_TextChanged"/>
In the class use the new method textBlock1_TextChanged
to treat.
In your class builder or event Loaded
, add that. Source
DependencyPropertyDescriptor dp = DependencyPropertyDescriptor.FromProperty(TextBlock.TextProperty, typeof(TextBlock));
dp.AddValueChanged(textblock_principal, (object a, EventArgs b) =>
{
// texto alterado!
});
Browser other questions tagged c# wpf events
You are not signed in. Login or sign up in order to post.
And if you used a Textbox taking out the styles, leaving it identical to Textblock?
– vinibrsl
I use
TexBlock
because of this property:TextTrimming="CharacterEllipsis"
, it seems that theTextBox
does not own this property.– Matheus Miranda