A TwoWay or OneWayToSource binding cannot work on the read-only property

前端 未结 1 1441
半阙折子戏
半阙折子戏 2020-12-12 23:27

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\" -

相关标签:
1条回答
  • 2020-12-12 23:38

    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}" />
    

    or from code:

    Binding binding = new Binding();
    binding.Mode = BindingMode.OneWay;
    
    0 讨论(0)
提交回复
热议问题