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

WpfBinding

Wpf Problem Overview


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...

Wpf Solutions


Solution 1 - Wpf

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;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTony Trembath-DrakeView Question on Stackoverflow
Solution 1 - WpfRazzieView Answer on Stackoverflow