Bookmark and Share Share...    Subscribe to this feed Feed   About me...


Override the default Style in WPF

If you want to replace the default style of a control you can define a "typed style". A typed style only has an implicit key. The key is the Type object of the TargetType. All controls beneath the definition will inherit the style automatically.

<Style TargetType="Button">
  <Setter Property="FontWeight" Value="Bold" />
</Style>
 
 
 
 



 Comments on this article

Show all comments
Dhruv
Commented on 20.April 2009
Really good concept in WPF styles .. Extensive use of object oriented programmin
Aravind
Commented on 1.June 2009
Hi,
There is one property called "overridesDefaultStyle" through which we can override default style and set our own styish button right? can u tell us, how to do that
DSCN4258
Commented on 5.August 2009
Ginkgo Biloba a herb that improves the flow of oxygen to the brain.;
tpartee
Commented on 21.August 2009
Too bad the TargetType DependencyProperty wants a REAL type, not a string. Your TargetType SHOULD read: {x:Type Button} instead. I hope you're not actually on Microsoft payroll...
Rajesh Kumar...
Commented on 25.August 2009
Good article, It's help me a lot to learn. Keep it up
bob b.
Commented on 17.September 2009
I'm not sure what version of the .NET runtime tpartee's using, but the markup given above is perfectly valid, although it is still valid to use the more verbose {x:Type Button} markup as well.
Yogee
Commented on 19.July 2010
Excellent article. This helped me a lot to learn WPF.

Name
E-Mail (optional)
Comment
About Christian Moser