且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WPF中ToggleButton的IsChecked属性的OneWay绑定

更新时间:2022-06-18 03:16:49

这是设计使用单向数据绑定时的。将附加的属性PresentationTraceSources.TraceLevel = High添加到绑定中,您将看到断开连接的时间。此链接也描述了问题(不提供任何解决方案):在WPF中调试数据绑定

This is by design when using oneway data binding. Add the attached property PresentationTraceSources.TraceLevel=High to your binding and you will see when it gets disconnected. This link describes the problem as well (without offering any solution): Debugging Data Binding in WPF

我通常解决的方法是使用命令进行用户交互,并在后面进行代码更改,以改变控件的外观更改的属性。

The way I normally solve it is to use a command for user interaction and code behind to change the control appearance because of some changed properties.