Posted By

jiewmeng on 09/04/10


Tagged

WPF


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


WPF: Styles & Triggers


 / Published in: C#
 

  1. <Window.Resources>
  2. <Style TargetType="Button">
  3. <Setter Property="Background" Value="Blue" />
  4. <Style.Triggers>
  5. <Trigger Property="IsMouseOver" Value="True">
  6. <Setter Property="FontWeight" Value="Bold" />
  7. </Trigger>
  8. </Style.Triggers>
  9. </Style>
  10. <Style x:Key="style1">
  11. <Setter Property="TextBlock.Padding" Value="20" />
  12. </Style>
  13. </Window.Resources>
  14. <StackPanel>
  15. <Button>This is a button</Button>
  16. <TextBlock Style="{StaticResource style1}">This is a text block</TextBlock>
  17. </StackPanel>

Report this snippet  

You need to login to post a comment.