CHJ124
CHJ124

Reputation: 131

How can I prevent wpf color properties from being overridden?

I am creating a user control which contains a border, a text box, and additional controls.

All the controls are contained within the border.

How do i prevent general styles from affecting the text box's within my user control?

For example, I have a style in my resource file that makes the text box's in my app have rounded corners. 99% of the time this is what I want. How do I prevent the text box's in my user control from being affected by that style?

Upvotes: 2

Views: 64

Answers (1)

Stewbob
Stewbob

Reputation: 16899

From MSDN:

Typically, the search will begin by walking up the element tree searching for an appropriate resource, then look in the application resource collection and finally query the system. This gives application developers a chance to redefine the style for any object at the tree or application level before reaching the theme.

http://msdn.microsoft.com/en-us/library/ms745683.aspx

So essentially, the closer(from a LogicalTree point of view) to the actual point of use that the Style or property is defined, the greater its level of precedence.

Upvotes: 1

Related Questions