Why is there no IsReadOnlyChanged event on TextBox controls?

喜你入骨 提交于 2019-12-07 22:52:28
Arsen Mkrtchyan

You can always follow dependency property change with DependencyPropertyDescriptor.AddValueChanged

DependencyPropertyDescriptor.FromProperty(TextBoxBase.IsReadOnlyProperty)
                            .AddValueChanged(ctrl, OnReadOnlyChanged)

Create a custom class and handle OnPropertyChanged event. Sth like this:

public class MyTextBox: TextBox
{
    public MyTextBox() { }
    protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    {
        base.OnPropertyChanged(e);
        if (e.Property.ToString() == "IsReadOnly")
        {
            // here you are sure that ContentPropertyhas changed
        }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!