KMC
KMC

Reputation: 20046

How to disable a TextBox while retaining its style

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?

Upvotes: 0

Views: 210

Answers (2)

kazinix
kazinix

Reputation: 30113

Check or set the property IsReadOnly of the TextBox to true.

Upvotes: 4

Related Questions