TextBlock
does not provide for user editing of text content, as it is just a lightweight control to display text (in windows store as in windows phone). Since its content can only be changed programmatically, there will be no event raised on change. You can see the events on TextBlock
here. In Windows Store apps there is also still a TextBox
control for user-editable text. This has a TextChanged
event.
If you really need to know when the Text
property is updated, you can set up a binding to that dependency property. You can create your own custom dependency property with change handler which provides you notification:
class MyClass {
public static readonly DependencyProperty MyTextProperty = DependencyProperty.Register("MyText", typeof(MyClass), typeof(string), new PropertyMetadata(null, OnMyTextChanged));
public static void OnMyTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
// Do something
}
}
Then you need to bind the property somewhere:
// myObj something of type MyClass
obj.SetBinding(textBlock, new Binding { Source = myObj, Path = new PropertyPath("MyText") });