开发者

Stretch the Checkbox to the cell size

开发者 https://www.devze.com 2023-04-07 15:47 出处:网络
I\'m using WPF and have DataGrid with checkbox column. the problem is that I would like the checkbox to stretch and fill the cell

I'm using WPF and have DataGrid with checkbox column. the problem is that I would like the checkbox to stretch and fill the cell

Stretch the Checkbox to the cell size

this is my XAML :

 <Grid>
    <Controls:DataGrid ItemsSource="{Binding Persons}" AutoGenerateColumns="False">
        <Controls:DataGrid.Columns>
            <Controls:DataGridTextColumn Binding="{Binding Name}"/>
            <Controls:DataGridTemplateColumn>
                <Controls:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox />
                    </DataTemplate>
                </Controls:DataGridTemplateColumn.CellTemplate>
            </Controls:DataGridTemplateColumn>
        </Controls:DataGrid.Columns>
    </Cont开发者_C百科rols:DataGrid>
</Grid>


You can put the CheckBox in a Viewbox, there will still be a small margin though which probably belongs to some control's Template, you could either try and change that template or mess with the Margin if you want to.

<Viewbox Margin="-1">
    <CheckBox/>
</Viewbox>
0

精彩评论

暂无评论...
验证码 换一张
取 消