如何将 DataGrid 标头的 XAML 宽度设置为*
?此代码不起作用:
<DataGrid>
<DataGrid.Resources>
<Style x:Key="CbClmn" TargetType="DataGridColumnHeader">
<Setter Property="Width" Value="30" />
</Style>
<Style x:Key="TxtClmn" TargetType="DataGridColumnHeader">
<Setter Property="Width" Value="*" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridCheckBoxColumn HeaderStyle="{StaticResource CbClmn}" />
<DataGridTextColumn Header="Title" HeaderStyle="{StaticResource TxtClmn}" />
<DataGridCheckBoxColumn Header="Selected" HeaderStyle="{StaticResource CbClmn}" />
</DataGrid.Columns>
</DataGrid>
样式TxtClmn
生成异常'*' string cannot be converted to Length
。