Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4155
Print and PrintPreviews from XamDataGrids with a GroupBy make first page small
posted

When i print or print preview using Reporting from my XamDataGrid, i the first page is rendered abnormally small, if I have a column GroupedBy. It only appears to take up about half of the page width.  The rest of the pages are fine.  What is the problem?  It only happens when there is GroupBy field, and only if i set 

report.ReportSettings.HorizontalPaginationMode = HorizontalPaginationMode.Scale; 

Included some of my code:
public PrintPreview(XamDataGrid grid, bool isLandscape, string title)
        {
            InitializeComponent();
 
            this.DataContext = this;
 
            if (Application.Current.MainWindow.IsLoaded)
            {
                this.Owner = Application.Current.MainWindow;
            }
 
            AddCommands();
 
            Grid = grid;
            Grid.AutoFit = true;
 
            EmbeddedVisualReportSection selection = new EmbeddedVisualReportSection(Grid);
 
            if (isLandscape)
            {
                report.ReportSettings.PageOrientation = PageOrientation.Landscape;
            }
            else
            {
                report.ReportSettings.PageOrientation = PageOrientation.Portrait;
            }
 
            //scale to fit all columns on the page? default spreads across pages mosaic etc.  -- Scale seems to make first page small if there is a groupby
            report.ReportSettings.HorizontalPaginationMode = HorizontalPaginationMode.Scale;
 
            //make column headers repeat every page
            report.ReportSettings.RepeatType = RepeatType.LevelBreak;  //PageBreak?
            
            //Add title if exists
            if (!String.IsNullOrEmpty(title))
            {
                report.PageHeaderTemplate = Application.Current.TryFindResource("PagePresenterHeaderTemplate"as DataTemplate;  //in Resources.ExplicitStylesResourceDictionary
                report.PageHeader = title;
            }
 
            //Add page numbering
            report.PageFooterTemplate = Application.Current.TryFindResource("PagePresenterFooterTemplate"as DataTemplate;
 
            report.Sections.Add(selection);
 
            ReportProgressControl progressInfo = new ReportProgressControl();
            progressInfo.Report = report;
 
            xamReportPreview1.GeneratePreview(report, truetrue);
        }

private XamDataGrid Grid { getset; }
        private Report report = new Report();
        private bool IsLandscape { getset; }