WPF: reverting brush to default/original WPF: reverting brush to default/original wpf wpf

WPF: reverting brush to default/original


You could use

_textBox.ClearValue(TextBox.BorderBrushProperty);

That will remove the directly assigned value and go back to the value defined by the style or template.


You can grab the default colours from the class SystemColors

Here is the list of all system colours:http://msdn.microsoft.com/de-de/library/system.windows.systemcolors.aspx

Default background colour of the client area:

     _textbox.Background = SystemColors.WindowBrush;

Default text colour inside the client area:

     _textbox.SystemColors.WindowTextBrush


I may be late to the party, but for future readers, you can also use Button.BackgroundProperty.DefaultMetadata.DefaultValue for this purpose. This is especially useful when you're using a Converter where you need to return a value and therefore cannot use ClearValue() call.