Hi Meppy
I need your help to set the width of report page dynamically based on screen resolution. My report is displayed inside a report window control and i want its size to be same as of report window. My present screen resolution(1600 by 900)
My report is inside the reportwindow.xaml control.
The report control fits itself according to screen resolution but not the report inside and so there comes a gap on the right side.
<Grid x:Name="LayoutRoot">
<Border CornerRadius="5" BorderBrush="#FF28607C" BorderThickness="1">
<Border.Background>
<LinearGradientBrush EndPoint="0.966,0.479" StartPoint="0.002,0.488">
<GradientStop Color="#FF65B1F0"/>
<GradientStop Color="#FFACE8F0" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="26"/>
<RowDefinition Height="22*"/>
<RowDefinition Height="423*" />
</Grid.RowDefinitions>
<Border x:Name="Header" Grid.Row="0" CornerRadius="4,4,0,0">
<Border.Background>
<LinearGradientBrush EndPoint="0.17,0.033" StartPoint="0.17,1.032">
<GradientStop Color="#FF134C6C" Offset="0"/>
<GradientStop Color="#FF2A627E" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock HorizontalAlignment="Left" x:Name="Title" TextWrapping="Wrap" Text="RESULTS: MAGAZINES Plan 1" VerticalAlignment="Center" Style="{StaticResource HeadingReport}" Margin="3,0,0,0" FontFamily="AvantGarde Bk BT" Foreground="White"/>
</Border>
<Border Background="White" Grid.Row="1" CornerRadius="0,0,3,3" Margin="3" BorderBrush="#FF1F4F6B" BorderThickness="1" Grid.RowSpan="2"></Border>
<report:ReportViewer Name="reportViewer" Grid.Row="1" Grid.RowSpan="2" Margin="5" PageMargins="0" Style="{StaticResource ReportViewerStyle1}" />
</Grid>
</Border>
</Grid>
I have a report handler class where I have tried to set the report viewer size.
if (report != null)
{
if (_prvm != null)
{
report.DataContext = _prvm;
}
report.QueryDetails += new EventHandler<QueryDetailsEventArgs>(report_QueryDetails);
report.Run();
if (_reportControl != null)
{
_reportControl.reportViewer.PageSize = new Size(_reportControl.ActualWidth, _reportControl.reportViewer.PageSize.Height);
//foreach (var page in report.Pages)
//{
// page.Size = new Dimension(_reportControl.ActualWidth, _reportControl.ActualHeight);
//}
_reportControl.reportViewer.Document = report;
}
}
But when the first time the report is loaded it doest change the page size and takes the default value. On consecutive calls the size is changed.
Please help me solve this issue.
Regards
Vikas