WPF: Styles & Triggers


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.