How to detect a change in the Text property of a TextBlock?

后端 未结 6 1674
梦如初夏
梦如初夏 2020-12-09 16:55

Is there any way to detect a change in the Text property of a TextBlock element using events?

(I\'m trying to provide an animation for highlighting the TextBlocks wh

6条回答
  •  我在风中等你
    2020-12-09 17:16

    It's easier than that! Late answer, but much simpler.

    // assume textBlock is your TextBlock
    var dp = DependencyPropertyDescriptor.FromProperty(
                 TextBlock.TextProperty,
                 typeof(TextBlock));
    dp.AddValueChanged(textBlock, (sender, args) =>
    {
        MessageBox.Show("text changed");
    });
    

提交回复
热议问题