lundi 3 janvier 2022

How to clear the margins of the corners of a checkbox in a listbox

enter image description here Please check the image.

There is a checkbox in the template in the listbox, and I set the red background color in it.

When I click on the red checkbox works fine.

But when I click on the image black arrow, it is not checked.

How can I clear the whitespace and synchronize it with the checkbox?

I tried setting margin padding but couldn't solve it.

        <ListBox x:Name="xList" Grid.Row="1" HorizontalContentAlignment="Stretch">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel Orientation="Vertical" IsItemsHost="True" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>

        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid Background="red">
                <CheckBox IsChecked="{Binding IsVisible, Mode=TwoWay}"
                          VerticalContentAlignment="Center" 
                          Content="{Binding Header}"
                          Height="28" />
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

Thank you for helping me.




Aucun commentaire:

Enregistrer un commentaire