WPF 精修篇 多属性触发器

原文: WPF 精修篇 多属性触发器

多属性触发器就是多个属性都满足在触发 

在属性触发器上加了一些逻辑判断

举栗子

这个栗子里  textBox 要满足俩个条件 才能触发背景变色

1)textbox的 IsEnabled 为true 

2) Texbox获得焦点


  
  
  1. <Window.Resources>
  2. <Style TargetType= "{x:Type TextBox}">
  3. <Style.Triggers>
  4. <MultiTrigger>
  5. <MultiTrigger.Conditions>
  6. <Condition Property= "IsEnabled" Value= "True"></Condition>
  7. <Condition Property= "IsKeyboardFocused" Value= "True"></Condition>
  8. </MultiTrigger.Conditions>
  9. <MultiTrigger.Setters>
  10. <Setter Property= "Background" Value= "Coral"/>
  11. </MultiTrigger.Setters>
  12. </MultiTrigger>
  13. </Style.Triggers>
  14. </Style>
  15. </Window.Resources>
  16. <Grid>
  17. <TextBox x:Name= "ss" Text= "多属性触发器" VerticalAlignment= "Center"></TextBox>
  18. <TextBox x:Name= "ss1" Text= "多属性触发器" VerticalAlignment= "Center" Margin= "0,50,0,0"></TextBox>
  19. </Grid>

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/12075484.html
今日推荐