Say I have a grid, I click an object and it displays in a detail screen. I don't want the user to edit some data so I set the TextBox as disabled? Will binding work? Basically what I want is the TextBox to be greyed out or disabled? How about it in WPF? Can someone explain?
Yes, binding will work with a disabled textbox. For disabling the textbox you have three options:
Set the IsReadOnly property to true. This will not affect the appearance of the textbox, but will stop the user changing the value inside it.
Set IsEnabled to false. This will gray out the textbox and stop it from receiving focus
Use a label or a textblock. This will place the text on screen without the appearence of being in an editable control at all.
As for binding, this will work the same no matter what you do. Set up the binding as normal in either the Xaml or codebehind and the value will update when the backing property changes as usual (provided you have implemented INotifyPropertyChanged, otherwise it'll only get set once)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With