有我的布局:
<DataGrid x:Name="BooksGrid"
DataContext="{Binding WorkingBooksSet, Mode=TwoWay}"
ItemsSource="{Binding}"
RowDetailsVisibilityMode="VisibleWhenSelected"
AutoGenerateColumns="False"
VerticalAlignment="Top" HorizontalAlignment="Stretch"
ColumnWidth="*">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id}" Width="Auto" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Title}" />
...
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding Publications, Mode=TwoWay}"
AutoGenerateColumns="False"
VerticalAlignment="Top" HorizontalAlignment="Stretch"
ColumnWidth="*">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id}" Width="Auto" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Publisher}" />
<DataGridTextColumn Binding="{Binding ReleaseYear}" />
...
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
这是一扇窗户
如您所见,女儿DataGrid
出于某种原因并没有填满所有可用空间,而是使它们变窄。此外,禁止手动调整列的大小。
我不理解这种行为,尤其是当“父”DataGrid
使用相同的代码正确显示时