Say I have a grid and I click an object and it displays in a detail screen,And I don't want the user to edit some data so I set the TextBox as disabled? then will binding work.Basically what I want is the TextBox to be greyed or disabled ya know? Well how about it in WPF? Can someone explain?
There is a IsReadOnly
property on the TextBox, just set it to true
I would use a <TextBlock/> or a <Label/> to display static data instead of a <TextBox/>.
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)