DataTrigger 当条件为 false 时设置默认值
这是我的 XAML:
<Ellipse Height="100" Width="100" Margin="35,112,0,0" Name="ellipse1" Fill="Red">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=checkBox1, Path=IsChecked}" Value="true">
<Setter Property="Ellipse.Visibility" Value="Collapsed"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<CheckBox Content="CheckBox" Height="16" Margin="42,79,168,166" Name="checkBox1" />
当选中该复选框时,椭圆当然会消失,但是当未选中它时,它会再次出现,但我不知道为什么。这种行为正常吗?为什么会发生这种情况?
So here is my XAML:
<Ellipse Height="100" Width="100" Margin="35,112,0,0" Name="ellipse1" Fill="Red">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=checkBox1, Path=IsChecked}" Value="true">
<Setter Property="Ellipse.Visibility" Value="Collapsed"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<CheckBox Content="CheckBox" Height="16" Margin="42,79,168,166" Name="checkBox1" />
When the checkbox is checked, of course the ellipse disappears but when it's unchecked, it appears again, but i don't know why. This behavior is normal? Why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
触发器恢复属性的原始值。
关于触发器和值
Trigger restores original value of property.
About trigger and value