Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Checkbox Datagrid not center #17870

Closed
chuongmep opened this issue Jan 2, 2025 · 3 comments
Closed

Custom Checkbox Datagrid not center #17870

chuongmep opened this issue Jan 2, 2025 · 3 comments
Labels

Comments

@chuongmep
Copy link

chuongmep commented Jan 2, 2025

Describe the bug

I tried to center header a checkbox custom but it can't same align with cell value
image

To Reproduce

Example :

 <DataGrid.Columns>
                        <!-- <DataGridCheckBoxColumn Binding="{Binding IsSelected}" Header="Check" /> -->
                        <DataGridTemplateColumn>
                            <DataGridTemplateColumn.Header>
                                <CheckBox HorizontalAlignment="Center"
                                          HorizontalContentAlignment="Center">
                                    <i:Interaction.Behaviors>
                                        <EventTriggerBehavior EventName="Click">
                                            <InvokeCommandAction Command="{Binding CheckAllCommand}" />
                                        </EventTriggerBehavior>
                                    </i:Interaction.Behaviors>
                                </CheckBox>
                            </DataGridTemplateColumn.Header>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox
                                        HorizontalAlignment="Center"
                                        Click="CheckList_click"
                                        IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
 </DataGrid.Columns>

Expected behavior

I hope align will be same

Avalonia version

11.2.3

OS

macOS

Additional context

No response

@chuongmep chuongmep added the bug label Jan 2, 2025
@timunie timunie added question and removed bug labels Jan 2, 2025
@timunie
Copy link
Contributor

timunie commented Jan 2, 2025

Use DevTools F12.to check is CheckBox has a MinWidth or Margin set

@chuongmep
Copy link
Author

Hi @timunie , MinWidth = 0 and Margin is 0,0,0,0, any help ?

@timunie
Copy link
Contributor

timunie commented Jan 3, 2025

Ah wait the header has a reserved space for SortIcon. You need to override this. Looking up the Theme for DataGridColumnHeader should help you.

@AvaloniaUI AvaloniaUI locked and limited conversation to collaborators Jan 3, 2025
@timunie timunie converted this issue into discussion #17884 Jan 3, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants