Styles have a set of properties; here I am going to place some of important and frequent used properties.
Setters: Sets the property values
Triggers: Change the style settings
Resources: Gets or Sets a collection of resources you can use
BasedOn: Creates a specialized style that inherits the settings of another style
TargetType: Gets or Sets the Control for which the style is intended
Let's have a basic example of this, shall we?
Copy and paste the below code in your window1.xaml
- <Window.Resources>
- <Style x:Key="wpfStyle1" TargetType="{x:Type TextBlock}">
- <Setter Property="FontFamily" Value="Verdana"/>
- <Setter Property="FontSize" Value="10"/>
- </Style>
- <Style x:Key="wpfStyle2" TargetType="{x:Type TextBlock}">
- <Setter Property="FontFamily" Value="Arial"/>
- <Setter Property="FontSize" Value="16"/>
- </Style>
- </Window.Resources>
- <Grid>
- <TextBlock Margin="26,41,39,0" Style="{StaticResource wpfStyle1}" Height="31" VerticalAlignment="Top">TextBlock with Style1</TextBlock>
- <TextBlock Margin="26,77,39,0" Height="32" VerticalAlignment="Top">TextBlock with no Style</TextBlock>
- <TextBlock Margin="26,113,67,88" Style="{StaticResource wpfStyle2}">TextBlock with Style2</TextBlock>
- </Grid>
The code seen above creates a Style in the <Window.Resources>. That Style targets elements of type TextBlock, and sets their FontFamily and FontSize properties. Notice that the Styles have keys named wpfStyle1, wpfStyle2. The Style property on each TextBlock is then explicitly set to reference that Style.
Conclusion
This article would help you understand the styles in WPF.

Wee GaryPosted Apr 26, 2022, 11:32 AM EDT
This is really clear demonstration. Thanks
Debasis SahaTOP 100Posted Jun 30, 2015, 8:44 PM EDT
Thanks for the article..
RakeshPosted Jun 30, 2015, 8:20 PM EDT
Good one sir
Gopi ChandPosted Jun 30, 2015, 7:22 PM EDT
Great sir...
Santhakumar MunuswamyPosted Jun 30, 2015, 10:26 AM EDT
Thanks for nice article sir.
Charwaka ThupiliPosted Jun 30, 2015, 6:10 AM EDT
Inofrmative
Nilesh JadavPosted Jun 30, 2015, 5:54 AM EDT
Thank you for sharing sir !
Vipul MalhotraPosted Jun 30, 2015, 3:56 AM EDT
nice article
Rajeesh MenothPosted Jun 30, 2015, 3:44 AM EDT
Nice one