|WPF| Checkbox Style.Trigger我没有写取消的Trigger,为什么点取消后他能恢复默认

javamy012 2012-10-08 08:35:04

<Window x:Class="SRQC11_5_2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="CheckBox">
<Style.Triggers>
<Trigger Property="IsChecked" Value="true">
<Trigger.Setters>
<Setter Property="FontSize" Value="20"></Setter>
<Setter Property="Foreground" Value="Orange"></Setter>
</Trigger.Setters>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<CheckBox Content="悄悄的我走了" Margin="5"></CheckBox>
<CheckBox Content="正如我悄悄的来" Margin="5"></CheckBox>
<CheckBox Content="我挥一挥衣袖" Margin="5"></CheckBox>
<CheckBox Content="不带走一片去彩" Margin="5"></CheckBox>
</StackPanel>
</Window>


这什么我没有写<Trigger Property="IsChecked" Value="false">的Trigger,为什么点取消后他能恢复默认
...全文
209 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
iyomumx 2012-10-08
  • 打赏
  • 举报
回复
事件触发和属性触发不一样的……
javamy012 2012-10-08
  • 打赏
  • 举报
回复
如果按上面说的:当IsChecked值不为True时,相应Trigger的Setter失效
那为什么我这个鼠标移开后按钮不会还原呢?

<Window x:Class="SRQC11_5_5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="Button">
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="150" Duration="0:0:0:1" Storyboard.TargetProperty="Width"></DoubleAnimation>
<DoubleAnimation To="150" Duration="0:0:0:1" Storyboard.TargetProperty="Height"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Canvas>
<Button Width="40" Height="40" Content="40"/>
</Canvas>
</Window>

iyomumx 2012-10-08
  • 打赏
  • 举报
回复
当IsChecked值不为True时,相应Trigger的Setter失效
javamy012 2012-10-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
没写就用的默认值啊
[/Quote]
问题是我的Trigger的触发器当为True的时候已经将他进行改变了,但我没有写=False的Trigger啊。
也就是没有False的触发器对他的字段进行改变啊
Hauk 2012-10-08
  • 打赏
  • 举报
回复
没写就用的默认值啊

110,825

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧