Dot NET
Dot NET

Reputation: 4897

How to change BorderBrush colour to default

I'm trying to change the BorderBrush colour of a TextBox to the default value. After looking at the ControlTemplate, it seems that no default colour is specified. Any idea what the default colour is?

This seems to be the ControlTemplate.

I found numerous examples for the XAML, however I need this to be done in code-behind like so:

txtValue1.BorderBrush = Brushes.Gray;

Upvotes: 1

Views: 5454

Answers (1)

dowhilefor
dowhilefor

Reputation: 11051

If you truly want the default value of the property, call

txtValue1.ClearValue(Border.BorderBrushProperty);

But this will change the property back to its initial value(in this case i would guess black or transparent). I'm not sure, but i guess you want the original color giving the currently used theme. So if you want local changes to be cleared, you can use GetLocalValueEnumerator and query for all local set properties and find the property where you want to clear the value. But if you have a custom style on the element you are using and you want to revert one property out of that, i don't think thats easily possible.

For that matter, this is an important read.

Upvotes: 4

Related Questions