The default TextBox
in WPF, once set isEnabled to False, the whole TextBox
is grayed out. I want to protect the TextBox.Text
from being modified and want the TextBox
to remain its style (ForeGround and Background color). Is there an easy work around to achieve this, other than to write the template to override the TextBox
?
Asked
Active
Viewed 198 times
0
2 Answers
4
Check or set the property IsReadOnly of the TextBox to true.

kazinix
- 28,987
- 33
- 107
- 157
-
@Pranay http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.textboxbase.isreadonly.aspx – Matt Hamilton Aug 01 '11 at 09:18
-
There is indeed a TextBox.IsReadOnly property in WPF, and this is a valid answer. Why the downvotes? – Matt Hamilton Aug 01 '11 at 09:19
-
2@Pranay Rana: Actually there is no `IsReadOnly` property in html attributes, in wpf there is. – Cheng Chen Aug 01 '11 at 09:22
-
maybe they just don't like the way I answered, its like uncertain. I've edited it. Forgive them. – kazinix Aug 01 '11 at 09:28