【发布时间】:2020-11-25 19:07:39
【问题描述】:
所以我有这个CheckBox Style 基于MaterialDesignActionCheckBox:
<Style x:Key="MaterialDesignActionAccentCheckBox2" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignActionCheckBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Ellipse x:Name="ellipse"
Width="15"
Height="15"
Fill="#353535"/>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="ellipse" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="ellipse" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Transparent"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontSize" Value="10"/>
</Trigger>
</Style.Triggers>
</Style>
当CheckBox 被选中时,我确实想要V 符号,所以我将它设为Transparent(在IsChecked 下)并输入Ellipse。
添加此ControlTemplate.Triggers 后,我看不到我的Ellipse。
我想做的就是在我的Checkbox 中显示这个Ellipse。
【问题讨论】:
标签: wpf checkbox styles material-design controltemplate