mardi 24 novembre 2020

WPF: override MaterialDesign check box style

So I have this CheckBox Style based on 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>

And i did now wanted the V sign when the CheckBox is checked so I Make it Transparent (under IsChecked true) and put Ellipse. After I added this ControlTemplate.Triggers I cannot see my Ellipse. All I want to do is to show this Ellipse inside my Checkbox




Aucun commentaire:

Enregistrer un commentaire