如何设置 UWP Toolkit DataGrid 行的高度?
How to set height of the UWP Toolkit DataGrid row?
使用此 MSDN 提示,我尝试设置 UWP Toolkit DataGrid 行的高度但没有成功。
https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/sizing_options
Sizing Rows and Row Headers DataGrid Rows By default, a DataGrid row's
Height property is set to Double.NaN ("Auto" in XAML), and the row
height will expand to the size of its contents. The height of all rows
in the DataGrid can be specified by setting the DataGrid.RowHeight
property. Users cannot change the row height by dragging the row
header dividers.
我试过以下方法
RowHeight="12" of the DataGrid
DataGridTemplateColumn -> TextBlock Height="12"
没有任何效果。
XAML
<toolkit:DataGrid ItemsSource="{x:Bind TripEvents, Mode=OneWay}"
x:Name="dataGridTripEvents"
HeadersVisibility="Column"
SelectionMode="Single"
GridLinesVisibility="Horizontal"
RowHeight="12">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTemplateColumn Header="#">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Height="12" FontSize="10" Text="{Binding NumberByOrder, Mode=OneWay}" Margin="2,2,2,2" Padding="2,2,2,2">
</TextBlock>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
请帮忙!谢谢!
请查看源代码here,最小高度为32,如果您设置的值小于32,则不会生效。
<Style TargetType="local:DataGridCell">
<Setter Property="Background" Value="{ThemeResource DataGridCellBackgroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="IsTabStop" Value="False"/>
使用此 MSDN 提示,我尝试设置 UWP Toolkit DataGrid 行的高度但没有成功。
https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/sizing_options
Sizing Rows and Row Headers DataGrid Rows By default, a DataGrid row's Height property is set to Double.NaN ("Auto" in XAML), and the row height will expand to the size of its contents. The height of all rows in the DataGrid can be specified by setting the DataGrid.RowHeight property. Users cannot change the row height by dragging the row header dividers.
我试过以下方法
RowHeight="12" of the DataGrid
DataGridTemplateColumn -> TextBlock Height="12"
没有任何效果。
XAML
<toolkit:DataGrid ItemsSource="{x:Bind TripEvents, Mode=OneWay}"
x:Name="dataGridTripEvents"
HeadersVisibility="Column"
SelectionMode="Single"
GridLinesVisibility="Horizontal"
RowHeight="12">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTemplateColumn Header="#">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Height="12" FontSize="10" Text="{Binding NumberByOrder, Mode=OneWay}" Margin="2,2,2,2" Padding="2,2,2,2">
</TextBlock>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
请帮忙!谢谢!
请查看源代码here,最小高度为32,如果您设置的值小于32,则不会生效。
<Style TargetType="local:DataGridCell">
<Setter Property="Background" Value="{ThemeResource DataGridCellBackgroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="MinHeight" Value="32"/>
<Setter Property="IsTabStop" Value="False"/>