jeudi 29 octobre 2020

How to decrease the padding between my checkbox and text next to it in xaml?

I'm writing code for a task pane with limited real estate. There is a select all checkbox and other checkboxes on the left side that are invisible until mouseover. There is too much space between the checkbox and the text and I'd like to reduce it. Have tried horizontal alignment, margin, padding, manually setting the width. What else is there to try?

            <DataGridTemplateColumn>
                <DataGridTemplateColumn.HeaderTemplate>
                    <DataTemplate>
                        <Border x:Name="cbkBorder" Background="Transparent" HorizontalAlignment="Left" Margin="-1" Width="15">
                        <CheckBox IsChecked="{Binding DataContext.SelectAll, Mode=TwoWay,
                                   RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
                                <CheckBox.Style>
                                    <Style TargetType="CheckBox">
                                        <Setter Property="Visibility" Value="Hidden"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=cbkBorder, Path=IsMouseOver}" Value="True">
                                                <Setter Property="Visibility" Value="Visible"/>
                                                <Setter Property="Cursor" Value="Hand" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </CheckBox.Style>
                            </CheckBox>
                        </Border>
                    </DataTemplate>
                </DataGridTemplateColumn.HeaderTemplate>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox Name="cbkSelect" HorizontalAlignment="Left" Margin="-1" Width="15" Padding="0"
                           IsChecked="{Binding Path=IsSelectedForOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <CheckBox.Style>
                                <Style TargetType="{x:Type CheckBox}">
                                    <Setter Property="Visibility" Value="Hidden"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True">
                                            <Setter Property="Visibility" Value="Visible"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </CheckBox.Style>
                        </CheckBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>



Aucun commentaire:

Enregistrer un commentaire