mercredi 2 décembre 2020

Changing checkmark color of a checkbox in a WPF ListView

I am trying to change the color of a checkmark of a checkbox in a WPF List View. I got the following XAML Code from another post. Unfortuantely I am not familar enough with the whole framework to understand where exacatly I need to add that in my ListView. Is anyone able to give me some hint. Many thanks in adavance.

<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="ScrollViewer">
    <Setter Property="Template">
        <Setter.Value>

            <ControlTemplate TargetType="CheckBox">
                <Grid>
                    <Path x:Name="Equis" Opacity="0" Stroke="Red" Fill="Red" Stretch="UniformToFill" StrokeThickness="20" Data="M 30,100 L 80,140 L 160,60" Margin="0,0,2,2" />
                    <ContentPresenter Margin="4" HorizontalAlignment="Left" VerticalAlignment="Top" />
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsChecked" Value="true">
                        <Setter TargetName="Equis" Property="Opacity" Value="1" />
                    </Trigger>
                    <Trigger Property="IsChecked" Value="false">
                        <Setter TargetName="Equis" Property="Opacity" Value="0" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Here the XAML of the checkbox in the GridViewColumn (works fine)

<GridViewColumn Header="HeaderName" Width="35">

    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <CheckBox x:Name="CheckBoxName" IsChecked="{Binding Object}" HorizontalAlignment="Center"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>

</GridViewColumn>



Aucun commentaire:

Enregistrer un commentaire