Bound Grids -- not creating the right DesiredSize: Fail to page properly

Jan 9, 2012 at 8:17 PM
Edited Jan 9, 2012 at 9:29 PM

I am building a fairly sophisticated (but not wildly so) report that has a variable number of rows and columns.

Unfortunately, as I walk through the "BuildReport" method, the DesiredSize of each row of information (which is bound to a datagrid) comes out at a measly 64 pixels (vs the 28 or so lines of data I have bound to it.

Is there a way to get the actual size sooner, so that the size is properly estimated and we trip teh "next page" concerpt.

Is this implementation such that any "unknown" binding size will not work ?


Here is my XAML for the report template:


     <!--Item template -->
                        <!-- The Grid -->
                        <Grid >
                                <RowDefinition Height="34" />
                                <RowDefinition Height="*" />
                            <Grid   Grid.Row="0"

                                <TextBlock  Margin="1,1,1,2" HorizontalAlignment="Center"
                                        Text="{Binding Path=Header}" Style="{StaticResource TitleTextStyle}" 

                            <sdk:DataGrid  Grid.Row="1" 
                                x:Name="OQGrid" AutoGenerateColumns="False" ItemsSource="{Binding QualRows}">
                                <sdk:DataGridTextColumn Binding="{Binding QualificationCode}"  Header="Code"/>
                                <sdk:DataGridTextColumn Binding="{Binding QualificationName}"  Header="Name"/>
                                <sdk:DataGridTemplateColumn Width="*">
                                        <Style TargetType="primitives:DataGridColumnHeader">
                                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                            <Setter Property="VerticalContentAlignment"  Value="Stretch" />
                                            <Setter Property="Margin" Value="0" />
                                            <Setter Property="ContentTemplate">
                                                        <ItemsControl  ItemsSource="{Binding DataContext.WorkerNames, ElementName=OQGrid}">
                                                                    <StackPanel Orientation="Horizontal">
                                                                    <Border  Width="70" >
                                                                        <TextBlock Text="{Binding}"  TextWrapping="Wrap" Margin="2"
                                            <ItemsControl  ItemsSource="{Binding WorkerQualified}">
                                                        <StackPanel Orientation="Horizontal"/>
                                                        <Border Width="70">
                                                            <CheckBox IsChecked="{Binding}"  HorizontalAlignment="Center"/>

Jan 9, 2012 at 9:36 PM

Is there a specific reason you're using a DataGrid for this? The DataGrid is a pretty heavy control meant for interactivity.

I haven't tested the report with datagrids. Although there has been a request to be able to build a report based on one, using the grid itself for report display is not on my list.

Also, it looks like you're creating a separate datagrid for each row in the report. I'm not sure how big the report will be, but that could be a LOT of datagrids. Memory for the app would likely go a bit nuts.


Jan 9, 2012 at 9:40 PM

Datagrid was easy because it was bound.  This construct created the columns (up to 8) and rows (up to 30) .. so it really doesn't get that big.

Anyway, I modified the approach by creating an interface for the datacontext called "Clues", and put SuggestedHeight on the context if I feel it can't figure it out.

Also -- would be useful to do a scale transform if a single object could not fit.


I like your basic approach !