TwoWay or OneWayToSource binding cannot work on a read-only property

I have a read-only property that needs to be displayed in a text box and get this error at runtime. I set IsEnabled="False" , IsReadOnly="True" - no luck. Other searches say readonly should fix this, but not for me. I have an ugly workaround by adding a dummy setter ...

+72
wpf binding
Feb 26 '09 at 12:06
source share
1 answer

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

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

or from code:

 Binding binding = new Binding(); binding.Mode = BindingMode.OneWay; 
+124
Feb 26 '09 at 12:14
source share



All Articles