我想继续检查标签的内容?

Let*_*oir 1 c# wpf label

我想继续检查标签的内容,如果标签更改我需要触发事件.我有一个日,周或月的枚举,如果其中一个值出现在标签中,我想根据标签中的值更改我的图表?

Ami*_*mit 6

您可以使用以下代码来了解内容何时更改

DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ContentControl.ContentProperty, typeof(Label));
            if (dpd != null)
            {
                dpd.AddValueChanged(label1, delegate
                {
                    // Add property change logic.
                });
            }
Run Code Online (Sandbox Code Playgroud)

在"//添加属性更改逻辑",您可以检查标签的内容广告触发事件或执行您想要的任何操作.