一个双向或者OneWayToSource结合不能在只读属性工作 [英] A TwoWay or OneWayToSource binding cannot work on the read-only property

查看:187
本文介绍了一个双向或者OneWayToSource结合不能在只读属性工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只读我需要一个文本框来显示属性,在运行时收到此错误。我给自己定 IsEnabled =FALSE IsReadOnly =真 - 没有运气。
其他搜索说只读应该修复它,但不适合我。
我已经加上空二传手得到一个丑陋的解决办法...

I've a read only property I need to display in a textbox, and getting this error at runtime. I've set IsEnabled="False", IsReadOnly="True" - no luck. Other searches say the readonly should fix it, but not for me. I've got an ugly workaround by adding a dummy setter...

推荐答案

这很难不code猜测,但你应该能够在BindingMode设置为单向。

It's hard to guess without code, but you should be able to set the BindingMode to OneWay.

<TextBox Text="{Binding Path=MyProperty, Mode=OneWay}" />

或code:

Binding binding = new Binding();
binding.Mode = BindingMode.OneWay;

这篇关于一个双向或者OneWayToSource结合不能在只读属性工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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