Hi Support,
We are currently using XamReportPreview control (WPF 14.2) version to preview the grid data. At a given time in the xamdatagrid we have approximately 5000 records with minimum 50 columns(the columns are dynamic); previewing these many records using XamReportPreview control takes quite a bit of time to generate the preview. We even tried previewing 1000 records using this control, however it took around 34 second to generate preview for 1000 records. Also we found some related post for the same but not found any specific workaround. Can you please let us know if there is any way to reduce the time to generate the preview for bulk data.
Also we are trying to convert .xls into .xps to show preview using "DocumentViewer" control of WPF. So can you please let us know if Infragitiscs has any other control or method to convert the excel file to the “XPS” document format?
--Related threads
http://www.infragistics.com/community/forums/t/73053.aspx
http://www.infragistics.com/community/forums/t/73499.aspx
http://www.infragistics.com/community/forums/t/66682.aspx
Thank you
Hi Rheal Tech,
As Stefan mentioned in those forum threads, doing a print preview on a grid with that many rows and columns is pretty cpu intensive. You have to remember that in order for the grid to be displayed inside the preview, it needs to render every single cell for every column and every row. In the case of 5000 records and 50 columns, that is 250,000 cells. That is 250,000 cells that need to be created and rendered inside the preview. Each cell has it's own internal components as well so there is a lot going on.
I think Stefan's approach in that second forum thread regarding a background thread is the best option. Generating the preview in a background thread means that the UI thread is not blocked so it leaves you with a responsive application.
One thing you can try is to create a CellValuePresenter style that is a stripped down version of the default one. The template for the CellValuePresenter should contain as few visual elements as possible. During the export, provide this stripped down style to the XamDataGrid being previewed so that when the cells in the grid are being rendered, it will use the fewest number of visual elements possible per cell. This may help you cut down on the generation time.
Let me know if you have any questions
Thanks for quick response, Rob.
We have tried implementing your suggestion to create another style having target type "CellValuePresenter". For this we have created one hidden grid which have this "CellValuePresenter" style(having only one setter to change background color, for testing purpose of course) and bind some data and passing this grid object to preview control at runtime but it still takes too much time to preview the data.
We further tried using the "DocumentViewer" control to preview the data. However this control requires the input file in XPS format. Can you please let us know whether Infragistics has any control or tool that will convert the Excel file into XPS format?
Thanks.
If all you did in the style was change the background color then you will not see an improvement. This is because even though you did not specify a template for the style, the CellValuePresenter will still use the default template. The style needs to provide it's own template which contains as few elements as possible. A much better test would be to provide a template that contains just a TextBlock with the Text property set to something.
As for whether Infragistics has something that can convert an Excel file to XPS, we currently do not. The WPF Reporting framework you are using right now, though, can export a Report to XPS.
Thanks for the reply Rob.
We have tried implementing your solution to override the default CellValuePresenter style of XamDataGrid using ControlTemplate and inside ControlTemplate use put the TextBlock and bound its Text property to the value of CellValuePresenter. The problem we are facing is that we need to retain the rest of the formatting like (content alignment and masking only) to the same as before. Hence we used trigger on control template to set the property of TextBlock but the none of the trigger get invoked. Please look at the following line of code.
<Style x:Key="PreviewCellValuePresenterStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate x:Name="CellValuePresenterControlTemplate" TargetType="{x:Type igDP:CellValuePresenter}">
<TextBlock x:Name="ContentValuePresenter"
VerticalAlignment="Center"
Text="{TemplateBinding Content}"
Margin="4,3,4,4"/>
<ControlTemplate.Triggers>
<Trigger Property="HorizontalAlignment" Value="Right">
<Setter TargetName="ContentValuePresenter" Property="TextBlock.TextAlignment" Value="Right"></Setter>
</Trigger>
<Trigger Property="HorizontalContentAlignment" Value="Right">
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
But we are facing the issue is that the trigger on ControlTemplate never gets invoked. The columns in grid are dynamic and the columns of type int, decimal, double will have text-alignment set to right and some type of value masking on it and the rest of the columns set the alignment to Left.
Can you please look into it why the trigger is not getting invoked on CellValuePresenter or can we get the datatype of each field in Xaml so we can use trigger to set alignment based on the data type of that field. For this we have tried following code
<Style x:Key="PreviewCellValuePresenterStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <ContentPresenter x:Name="ContentValuePresenter" Content="{TemplateBinding Content}" VerticalAlignment="Center" Margin="4,3,4,4"> </ContentPresenter> <ControlTemplate.Triggers> <DataTrigger Binding="{Binding Path=Field.DataType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}}" Value="System.Decimal"> <Setter TargetName="ContentValuePresenter" Property="TextBlock.TextAlignment" Value="Right"/> </DataTrigger> <DataTrigger Binding="{Binding Path=Field.DataType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}}" Value="Decimal"> <Setter TargetName="ContentValuePresenter" Property="TextBlock.TextAlignment" Value="Right"/> </DataTrigger> <DataTrigger Binding="{Binding Path=Field.DataType, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}}" Value="{x:Type System:Decimal}"> <Setter TargetName="ContentValuePresenter" Property="TextBlock.TextAlignment" Value="Right"/> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
Thanks
You should use the EditAsTypeResolved property on the Field object. I used a converter on the trigger to determine if it was a numeric value, then returned true or false. Based on that I set the TextAlignment property on the TextBlock to Right. Take a look at my sample.