如果我使用“*”设置DataGrid(位于RowDetailesTemplate)列的宽度 - 列缩放不起作用
<DataGrid>
...
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid Margin="10" Height="100">
<DataGrid.Columns>
<DataGridTextColumn Header="header A" Width="3*" />
<DataGridTextColumn Header="header B" Width="2*" />
<DataGridTextColumn Header="header C" Width="*" />
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
但如果我用Grid替换DataGrid并使用“*”scailing works设置它的列宽
<Grid Margin="5" Height="100">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="header A" Background="LightGray" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
<TextBlock Text="header B" Grid.Column="1" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
<TextBlock Text="header C" Grid.Column="2" Background="LightGray" TextAlignment="Center" HorizontalAlignment="Stretch"></TextBlock>
</Grid>
如何修复DataGrid缩放?
溶液
<DataGrid HorizontalScrollBarVisibility="Disabled">
...
<DataGrid.RowDetailsTemplate>
...
</DataGrid.RowDetailsTemplate>
</DataGrid>