0

There is my layout:

<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>

And it's a window

As you can see, daughter DataGrid for some reason has not filled all the available space, instead made ​​them narrow. Moreover it is prohibited to manually resize the columns.

I do not understand this behavior, especially as the "parent" DataGrid displays correctly with the same code

Veikedo
  • 1,453
  • 1
  • 18
  • 25
  • 1
    I have come across the same problem. Except the part where you can 'manually resize the columns'. It's very odd behaviour. – BobWinters Feb 09 '14 at 12:03
  • 1
    Edit: The answer to the question [here](http://stackoverflow.com/questions/11956023/how-to-make-the-last-datagrids-column-occupy-the-whole-left-space) fixed it for me. Maybe my problem is different, hard to say. – BobWinters Feb 09 '14 at 13:13

1 Answers1

1

Add * width to one of the columns in your child DataGrid.

       <DataGrid.Columns>
          <DataGridTextColumn Binding="{Binding Id}" Width="Auto" IsReadOnly="True" />
          <DataGridTextColumn Binding="{Binding Publisher}" />
          <DataGridTextColumn Binding="{Binding ReleaseYear}" Width="*" />
          ...
        </DataGrid.Columns>
Rajiv
  • 1,426
  • 14
  • 21