为什么TextBox控件上没有IsReadOnlyChanged事件? [英] Why is there no IsReadOnlyChanged event on TextBox controls?

查看:326
本文介绍了为什么TextBox控件上没有IsReadOnlyChanged事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在添加一些解决方法代码来修复这是DotNet 4 WPF拼写检查中的错误?,(当WPF TextBox更改已启用时, 可见 ReadOnly 声明,任何SpellCheck自定义字典都将被删除,直到您禁用并重新启用SpellCheck),最简单的修复程序似乎是处理 IsVisibleChanged IsEnabledChanged IsReadOnlyChanged 事件。

I was adding some workaround code to fix the bug outlined in Is this a bug in DotNet 4 WPF Spell Checking?, (When a WPF TextBox changes Enabled, Visible or ReadOnly states, any SpellCheck custom dictionaries get dropped off until you disable and re-enable SpellCheck) and the simplest fix seemed to be to handle the IsVisibleChanged, IsEnabledChanged, and IsReadOnlyChanged events.

简单,对吧?除了 IsReadOnlyChanged 事件。任何人都知道为什么和什么最好的方式来陷入一个WPF文本框中的 IsReadOnly

Simple, right? Except there is no IsReadOnlyChanged event. Anybody know why and what the best way to trap a change to IsReadOnly in a WPF TextBox would be?

推荐答案

您可以随时使用 DependencyPropertyDescriptor.AddValueChanged

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

这篇关于为什么TextBox控件上没有IsReadOnlyChanged事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆