none
Why don't the row details of this DataGrid resize properly?

    Question

  • I have a DataGrid with a Grid in the row details and I am seeing somethign weird - if one of the columns' width is "*", the row details pane does not resize properly when resizing the window, namely, the pane resizes when the window size increases, but it does not shrink when the windows size shrinks.

    Does anybody have any idea what is going on?

    Here is a greatly simplified XAML that still exhibits the behavior (the code behind simply loads an XML file to supply the data):

    <Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xlinq="clr-namespace:System.Xml.Linq;assembly=System.Xml.Linq"
        Title="Test" Height="500" Width="800" Closing="MainWindow_Closing">
     <DockPanel Name="dockPanel1">
      <DataGrid AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="False"
           DataContext="{Binding Path=Doc.Elements[one]}" ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" >
       <DataGrid.Columns>
        <DataGridTextColumn Header="Name" />
        <DataGridTextColumn Header="Value" Width="*" />
       </DataGrid.Columns>
       <DataGrid.RowDetailsTemplate>
        <DataTemplate>
         <Grid>
          <Grid.RowDefinitions>
           <RowDefinition />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
           <ColumnDefinition />
           <ColumnDefinition />
          </Grid.ColumnDefinitions>
          <CheckBox Content="check 1" Grid.Column="0"></CheckBox>
          <CheckBox Content="check 2" Grid.Column="1"></CheckBox>
         </Grid>
        </DataTemplate>
       </DataGrid.RowDetailsTemplate>
      </DataGrid>
     </DockPanel>
    </Window>
    

    Monday, May 31, 2010 6:01 AM

Answers

  • Hmm, I thought a lot of people would have run into this, since it is so easy to reproduce, but no responses.

    Anyway, I found a workaround, thanks to this bug report: http://wpf.codeplex.com/WorkItem/View.aspx?WorkItemId=11915 . The workaround - adding HorizontalScrollBarVisibility="Disabled" to the DataGrid - also gets rid of my problem. This is really representative of what I keep finding while working with WPF - a great design, which should save time, but a half-baked and inconsistent implementation that has me wasting hours trying to debug data-driven code without sources.

    Tuesday, June 01, 2010 2:04 AM

All replies

  • Hmm, I thought a lot of people would have run into this, since it is so easy to reproduce, but no responses.

    Anyway, I found a workaround, thanks to this bug report: http://wpf.codeplex.com/WorkItem/View.aspx?WorkItemId=11915 . The workaround - adding HorizontalScrollBarVisibility="Disabled" to the DataGrid - also gets rid of my problem. This is really representative of what I keep finding while working with WPF - a great design, which should save time, but a half-baked and inconsistent implementation that has me wasting hours trying to debug data-driven code without sources.

    Tuesday, June 01, 2010 2:04 AM
  • Lucas! Just been having similar pain. I quite agree that there are some great ideas, but the whole process is very painful. On the plus side there's usually a way of doing something, on the downside you end up half rewriting controls to do it...

    The classic for me is drag and drop. Isn't it about time that was made a LOT easier. Even if only across the same application.

     

    Tuesday, September 14, 2010 3:53 PM