Datagrid: display too many elements

Feb 16, 2011 at 2:43 PM

Hello,

I'm trying to build an Excel AddIn which will browse some results stored in a database. I have 3 parent-child tables to display.

As you can see in my code, my 3 Datagrids are in a grid which contains 2 GridSplitter to allow the user to resize the display.

<Grid VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition ></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition ></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
            <DataGrid Grid.Row="0" DataContext="{Binding Source={StaticResource GpecsMeasurements}}" AutoGenerateColumns="False" Name="dgMeasurementDescriptor" ItemsSource="{Binding Path=MeasurementDescriptorList}" >
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Measure ID" Binding="{Binding Measure_id}" />
                    <DataGridComboBoxColumn Header="Operator" SelectedValuePath="Operator_id" SelectedValueBinding="{Binding Operator_id}" ItemsSource="{Binding Source={StaticResource GpecsMeasurements}, Path=OperatorList}"  DisplayMemberPath="Operator_name" />
                    <DataGridTextColumn Header="Order nr" Binding="{Binding Order_nr}"></DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
        <GridSplitter HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="1" Height="5" Foreground="LightBlue"></GridSplitter>
            <DataGrid Grid.Row="2" DataContext="{Binding ElementName=dgMeasurementDescriptor, Path=SelectedItem}" ItemsSource="{Binding Path=GPECS_Measure_Steps}" AutoGenerateColumns="False" Name="dgMeasurementStep"  >
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Measure ID" Binding="{Binding Measure_id}" />
                    <DataGridTextColumn Header="Step nr" Binding="{Binding Measure_step_nr}"></DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
        <GridSplitter HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="3" Height="5" Foreground="LightBlue"></GridSplitter>

        <DataGrid Grid.Column="0" Grid.Row="4" DataContext="{Binding ElementName=dgMeasurementStep, Path=SelectedItem}" ItemsSource="{Binding Path=GPECS_Acquired_Values}" AutoGenerateColumns="True" Name="dgAcquiredValues">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Measure ID" Binding="{Binding Measure_id}" />
                <DataGridTextColumn Header="Step nr" Binding="{Binding Measure_step_nr}"></DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
 

So far, so good but I'm not very happy with this solution and I would like to use 3 Expanders instead of GridSplitters. The idea is to use one expander per datagrid but I have several problems.

  1. In the first datagrid, there is more than 2500 elements and it take time to display them.
  2. When I open the top expander, it take all the available space and it is not possible to open the other expanders anymore.
  3. When I resize the windows, the datagrids don't resize at all.

Since I am new to WPF, any help would be really appreciated.

Christophe