or
private void Window_Loaded(object sender, RoutedEventArgs e){ // Instantiate the DataServiceContext. _context = new Vessel.Service.VesselService(_svcUri);}private void button_getvesselTypes_Click(object sender, RoutedEventArgs e){ try { StartStats(); var VTQuery = from v in _context.Vestype select v; DataServiceCollection<VestypeEntity> VesselTypes = new DataServiceCollection<VestypeEntity>(VTQuery); this._radgrid_output.DataContext = VesselTypes; ShowStats(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); }}<Window x:Class="TestClient.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="WCF oData Test" Width="750" Height="600" x:Name="OutputWindow" Loaded="Window_Loaded"> <Grid x:Name="grid_mainlayout"> <Grid.RowDefinitions> <RowDefinition x:Name="gridrow_detailsection" Height="*"></RowDefinition> <RowDefinition x:Name="gridrow_footersection" Height="60"></RowDefinition> </Grid.RowDefinitions> <telerik:RadGridView Name="_radgrid_output" Grid.Row="0" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding}" ItemsSource="{Binding}" EnableColumnVirtualization="True" EnableRowVirtualization="True" DataLoadMode="Asynchronous" IsReadOnly="True" ActionOnLostFocus="None" /> <StackPanel x:Name="stackpannel_buttons" Grid.Row="1" Orientation="Horizontal"> <Button x:Name="button_Query1" Margin="2,10,10,10" Width="100" Content="Get 6000 rows" Click="button_getvessels_Click"></Button> <Button x:Name="button_Query2" Margin="2,10,10,10" Width="100" Content="Get 80 rows" Click="button_getvesselTypes_Click"></Button> </StackPanel> </Grid> </Window><UserControl.Resources> <Style x:Key="Style1" TargetType="{x:Type Rectangle}"> <Setter Property="StrokeThickness" Value="12" /> <Setter Property="StrokeDashArray" Value="3 3"/> <Setter Property="Stroke" Value="Red"/> <Setter Property="Fill" Value="Transparent"/> </Style></UserControl.Resources> <telerik:RadDiagram x:Name="diagram" SelectionRectangleStyle="{DynamicResource Style1}" /> public static void PrintHeaderedContentControl(HeaderedContentControl VisualToPrint) { PrintDialog myPrintDialog = new PrintDialog(); if (myPrintDialog.ShowDialog() == true) { myPrintDialog.PrintVisual(VisualToPrint, VisualToPrint.Header.ToString()); } } // PrintHeaderedContentControlIf I try this with PrintHeaderedContentControl(myRadPane) I just get an empty page with only the header text.
Any Ideas what I can do get this to work?
the following the following
It turned out the control was printed but outside the printer paper. So we need to resize and transform the control to get it on paper with code like this:
Transform transOld = ControlToPrint.RenderTransform; TransformGroup myTransforms = new TransformGroup(); myTransforms.Children.Add(new ScaleTransform(dScale, dScale)); myTransforms.Children.Add(new TranslateTransform((myPrintDialog.PrintableAreaWidth - 20) / 20, (myPrintDialog.PrintableAreaHeight - 20) / 20)); ControlToPrint.LayoutTransform = myTransforms; Size pageSize = new Size(myPrintDialog.PrintableAreaWidth - 20, myPrintDialog.PrintableAreaHeight - 20); ControlToPrint.Measure(pageSize); ControlToPrint.Arrange(new Rect(10, 10, pageSize.Width - 10, pageSize.Height - 10)); myPrintDialog.PrintVisual(ControlToPrint, Title); ControlToPrint.LayoutTransform = transOld;