是否可以更改 WPF System.Windows.Controls.DataGrid 的单元格的大小?
说,我希望我所有的单元格都是大小(100 x 50)。
是否可以更改 WPF System.Windows.Controls.DataGrid 的单元格的大小?
说,我希望我所有的单元格都是大小(100 x 50)。
<DataGrid ...
    <DataGrid.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="Width" Value="100"/>
           <Setter Property="Height" Value="50"/>
        </Style>
    </DataGrid.CellStyle>
您是否尝试过设置 ColumnWidth 和 RowHeight?
 <DataGrid ColumnWidth="100" RowHeight="50"/>
可以在 Styling Microsoft 的 WPF datagrid中找到有关设置 DataGrid 样式的更多信息。
尝试这样的事情:
    <!--you can set Name and ItemsSource to other values, this is just a sample-->
    <DataGrid x:Name="dataGrid" ItemsSource="{Binding}">
        <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
                <Setter Property="Width" Value="100"/>
                <Setter Property="Height" Value="50"/>
            </Style>
        </DataGrid.CellStyle>
    </DataGrid>