How to create a styles in wpf

1)x:Key is the name of the style
2)TragetType:which control we want to inherit the style
3)Setter Property: we define the attributes where we want to  put our style


In following example we are defining  style for button and we are giving orange background for button,italic font style for fonts,

   <Window.Resources>

        <Style x:Key="myStyle" TargetType="Button">

           <Setter Property="Background" Value="Orange" />

           <Setter Property="FontStyle" Value="Italic" />

           <Setter Property="Padding" Value="8,4" />

           <Setter Property="Margin" Value="4" />

        </Style>

    </Window.Resources>















 













 




Ebook Download
View all
Learn
View all