【问题标题】:Stretch the Checkbox to the cell size将复选框拉伸到单元格大小
【发布时间】:2011-11-24 14:28:22
【问题描述】:

我正在使用 WPF 并拥有带有复选框列的 DataGrid。 问题是我希望复选框拉伸并填充单元格

这是我的 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>
    </Controls:DataGrid>
</Grid>

【问题讨论】:

    标签: wpf xaml datagrid


    【解决方案1】:

    您可以将CheckBox 放在Viewbox 中,尽管它可能属于某些控件的Template,但仍有一小部分余量,您可以尝试更改该模板或将Margin 弄乱,如果你想。

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

    【讨论】:

      猜你喜欢
      • 2015-01-01
      • 2013-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-15
      • 2011-08-25
      • 2023-03-03
      • 1970-01-01
      相关资源
      最近更新 更多