This question is locked. New answers and comments are not allowed.
Need some help with this. I can't be able to print composed bar charts. The
only output I get are the labels, so that I know I'm getting data back
and that it's not rendering correctly. I've attached an image of what
I'm able to get to print (directing printing to a file), here is the code:
*****MainPage******
****MAinPage.xaml.CS****
***Graphic to Print View***
***Graphic to print.xaml.CS*****
*****MainPage******
<UserControl x:Class="SoEmptyApp.MainPage" xmlns:telerik="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls" xmlns:System="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d"> <UserControl.Resources> <ResourceDictionary> <Style x:Key="AxisRightStyle" TargetType="TextBlock"> <Setter Property="FontFamily" Value="Arial Narrow"/> <Setter Property="FontSize" Value="12"/> <Setter Property="HorizontalAlignment" Value="Right"/> <Setter Property="TextWrapping" Value="Wrap"/> <Setter Property="MaxWidth" Value="115" /> <Setter Property="TextAlignment" Value="Right" /> </Style> <System:Double x:Key="BarRadiusY">1</System:Double> <System:Double x:Key="BarRadiusX">1</System:Double> <SolidColorBrush x:Key="BarOpacityMaskBrush" Color="#FF000000"/> <SolidColorBrush x:Key="BarMaskStroke" Color="Transparent"/> <System:Double x:Key="BarMaskStrokeThickness">0</System:Double> <LinearGradientBrush x:Key="relieve_top" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop/> <GradientStop Color="White" Offset="0.51"/> <GradientStop Color="Transparent" Offset="1"/> <GradientStop Color="White" Offset="0.51"/> </LinearGradientBrush> <SolidColorBrush x:Key="BarTopMaskReversedBrush" Color="Transparent"/> <LinearGradientBrush x:Key="derecha" EndPoint="-0.5,1" StartPoint="1.333,1"> <GradientStop Color="Black" Offset="0.147"/> <GradientStop Color="Transparent" Offset="1"/> </LinearGradientBrush> <Style x:Key="CustomStyle" TargetType="telerik:Bar"> <Setter Property="MaxHeight" Value="72"/> <Setter Property="MinHeight" Value="36" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:Bar"> <Border x:Name="PART_MainContainer" Opacity="0"> <Border.RenderTransform> <ScaleTransform x:Name="PART_AnimationTransform" ScaleX="0"/> </Border.RenderTransform> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="HoverStates"> <VisualState x:Name="Normal"/> <VisualState x:Name="Hovered"/> <VisualState x:Name="Hidden"/> </VisualStateGroup> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected"/> <VisualState x:Name="Selected"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0.00:00:00.05" Storyboard.TargetProperty="Stroke" Storyboard.TargetName="PART_SelectedState"> <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0"> <DiscreteObjectKeyFrame.Value> <SolidColorBrush Color="#B2000000"/> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Duration="0.00:00:00.05" Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="PART_SelectedState"> <DiscreteObjectKeyFrame KeyTime="0.00:00:00.0"> <DiscreteObjectKeyFrame.Value> <System:Double>2</System:Double> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid> <Rectangle x:Name="PART_DefiningGeometry" Style="{TemplateBinding ItemStyle}" /> <Grid OpacityMask="{StaticResource BarOpacityMaskBrush}" Background="{Binding DataItem.Color}" > <Grid.ColumnDefinitions> <ColumnDefinition MinWidth="0" MaxWidth="3" /> <ColumnDefinition /> <ColumnDefinition MinWidth="0" MaxWidth="3" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition MinHeight="0" MaxHeight="3" /> <RowDefinition /> <RowDefinition MinHeight="0" MaxHeight="3"/> </Grid.RowDefinitions> <Path Data="M2.9998684,104.98376 L3.0154941,107.98411 L-0.0002613106,107.99973" Fill="Black" Margin="0" Stretch="Fill" Stroke="{StaticResource BarMaskStroke}" StrokeThickness="{StaticResource BarMaskStrokeThickness}" UseLayoutRounding="False" Grid.Row="2" Opacity="0.5"/> <Rectangle Grid.Column="1" Grid.Row="2" Stroke="{StaticResource BarMaskStroke}" StrokeThickness="{StaticResource BarMaskStrokeThickness}" Opacity="0.5" Fill="Black"/> <Path Grid.Column="2" Data="M78.000725,105.03175 L81.029419,108.016 L78.000725,108" Margin="0" Stretch="Fill" Stroke="{StaticResource BarMaskStroke}" StrokeThickness="{StaticResource BarMaskStrokeThickness}" UseLayoutRounding="False" Grid.Row="2" Opacity="0.5" Fill="Black"/> <Path Grid.Column="2" Data="M77.983803,104.99992 L80.968552,107.985 L80.999809,104.99992" Margin="0" Stretch="Fill" UseLayoutRounding="False" Grid.Row="2" Fill="{StaticResource derecha}"/> <Rectangle Grid.Column="2" Grid.Row="1" Fill="{StaticResource derecha}"/> <Path Grid.Column="2" Data="M81.015572,0.00082016352 L81.015198,2.9998338 L77.999153,3.0008335" Fill="{StaticResource derecha}" Margin="0" Stretch="Fill" UseLayoutRounding="False"/> <Path Grid.Column="2" Data="M81.030472,-0.014555448 L77.999771,3.0050786 L77.999771,0.0010077506" Margin="0" Stretch="Fill" UseLayoutRounding="False" Fill="{StaticResource relieve_top}"/> <Rectangle Grid.Column="1" Fill="{StaticResource relieve_top}"/> <Path Data="M-0.021426115,0.00011788693 L2.9987607,2.9996433 L3.0407479,-0.062875763" Fill="{StaticResource relieve_top}" Margin="0" Stretch="Fill" UseLayoutRounding="False"/> <Rectangle Grid.Column="1" Grid.Row="1" Opacity="0.45"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop/> <GradientStop Color="Black" Offset="1"/> <GradientStop Color="Transparent" Offset="0.309"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> </Grid> <Rectangle x:Name="PART_SelectedState" Fill="{StaticResource BarTopMaskReversedBrush}"/> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <!--ReTemplate RadChart, to allow view the Annotations over the Chart--> <SolidColorBrush x:Key="ChartAreaBackground" Color="Transparent" /> <Style x:Key="CustomChartArea" TargetType="telerik:ChartArea"> <Setter Property="Template2D"> <Setter.Value> <ControlTemplate TargetType="telerik:ChartArea"> <Border Padding="{TemplateBinding Padding}" Margin="{TemplateBinding Margin}" Background="{TemplateBinding Background}"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto" /> <RowDefinition Height="*" /> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> <telerik:AxisX2D x:Name="PART_AxisX" Style="{TemplateBinding AxisXStyle}" Grid.Row="2" Grid.Column="1" /> <telerik:AxisY2D x:Name="PART_AxisY" Style="{TemplateBinding AxisYStyle}" Grid.Row="1" Grid.Column="0" /> <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalHorizontalAxesPanel" Grid.Row="0" Grid.Column="1" StackOrientation="Vertical" /> <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalVerticalAxesPanel" Grid.Row="1" Grid.Column="2" StackOrientation="Horizontal" Height="{TemplateBinding Height}" /> <telerik:ClipPanel x:Name="PART_PlotAreaPanel" Grid.Row="1" Grid.Column="1" Style="{TemplateBinding PlotAreaStyle}"> <telerik:HorizontalStripLines2D x:Name="PART_HorizontalStripLines" /> <telerik:VerticalStripLines2D x:Name="PART_VerticalStripLines" /> <telerik:VerticalMinorGridLines2D x:Name="PART_VerticalMinorGridLines" /> <telerik:HorizontalMinorGridLines2D x:Name="PART_HorizontalMinorGridLines" /> <telerik:HorizontalGridLines2D x:Name="PART_HorizontalGridLines" /> <telerik:VerticalGridLines2D x:Name="PART_VerticalGridLines" /> <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaHorizontalAxesPanel" StackOrientation="Vertical" /> <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaVerticalAxesPanel" StackOrientation="Horizontal" /> <telerik:DragZoomLayerControl x:Name="PART_DragZoomLayer" Style="{TemplateBinding DragZoomLayerControlStyle}"> <Grid> <ItemsPresenter /> <telerik:AnnotationLayer x:Name="PART_AnnotationLayer" ItemsSource="{TemplateBinding Annotations}" /> </Grid> </telerik:DragZoomLayerControl> <telerik:PlotAreaAxisY2D x:Name="PART_PlotAreaAxisY" Style="{TemplateBinding PlotAreaAxisYStyle}" /> <telerik:PlotAreaAxisX2D x:Name="PART_PlotAreaAxisX" Style="{TemplateBinding PlotAreaAxisXStyle}" /> <telerik:LabelsPanel x:Name="PART_LabelsPanel"/> </telerik:ClipPanel> <telerik:NoDataControl x:Name="PART_NoData" Grid.RowSpan="3" Grid.ColumnSpan="3" Style="{TemplateBinding NoDataControlStyle}" /> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="ItemsPanel" > <Setter.Value> <ItemsPanelTemplate> <telerik:ChartPanel /> </ItemsPanelTemplate> </Setter.Value> </Setter> <Setter Property="Background" Value="{StaticResource ChartAreaBackground}" /> <Setter Property="Padding" Value="5,10,10,5" /> </Style> <Style x:Key="CustomLabelStyle" TargetType="telerik:SeriesItemLabel"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="Padding" Value="2,0" /> <Setter Property="IsHitTestVisible" Value="False"/> <Setter Property="Template" > <Setter.Value> <ControlTemplate TargetType="telerik:SeriesItemLabel"> <Canvas> <Polyline x:Name="PART_Connector" Points="{TemplateBinding ConnectorPoints}" Visibility="{TemplateBinding ConnectorVisibility}" Style="{TemplateBinding ConnectorStyle}" Stroke="{TemplateBinding Stroke}" StrokeThickness="{TemplateBinding StrokeThickness}" /> <Border x:Name="PART_TextContainer" BorderBrush="{TemplateBinding Stroke}" Background="Transparent"> <TextBlock TextAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Foreground="Black" FontWeight="ExtraBold" Text="{TemplateBinding Content}" /> </Border> </Canvas> </ControlTemplate> </Setter.Value> </Setter> </Style> <DataTemplate x:Key="DataTemplate"> <Grid x:Name="GridTemplate"> <Grid.ColumnDefinitions> <ColumnDefinition Width="5"/> <ColumnDefinition/> <ColumnDefinition Width="5"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="35"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Controls:RadChart ItemsSource="{Binding}" Margin="0" x:Name="chartHorizontal" BorderBrush="Black" Background="White" telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" AxisElementBrush="Black" Grid.Row="1" Grid.Column="1" MaxWidth="130"> <Controls:RadChart.SeriesMappings> <telerik:SeriesMapping> <telerik:SeriesMapping.SeriesDefinition> <telerik:HorizontalBarSeriesDefinition ItemLabelFormat="{Binding DataContext.Data.NumberFormat, ElementName=LayoutRoot}" ItemStyle="{StaticResource CustomStyle}" SeriesItemLabelStyle="{StaticResource CustomLabelStyle}"> <telerik:HorizontalBarSeriesDefinition.LabelSettings> <telerik:BarLabelSettings LabelDisplayMode="MidPoint" /> </telerik:HorizontalBarSeriesDefinition.LabelSettings> </telerik:HorizontalBarSeriesDefinition> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping FieldName="YValue" DataPointMember="YValue" /> <!--<telerik:ItemMapping FieldName="Categoria" DataPointMember="XCategory"/>--> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> </Controls:RadChart.SeriesMappings> <Controls:RadChart.DefaultView> <telerik:ChartDefaultView> <telerik:ChartDefaultView.ChartLegend> <telerik:ChartLegend Visibility="Collapsed"> </telerik:ChartLegend> </telerik:ChartDefaultView.ChartLegend> <telerik:ChartDefaultView.ChartArea> <telerik:ChartArea EnableAnimations="False" Margin="0,0,0,0" BorderThickness="0" BorderBrush="#FF3D2C2C" PaletteBrushesRepeat="True" VerticalAlignment="Stretch" Style="{StaticResource CustomChartArea}"> <telerik:ChartArea.Annotations> <telerik:CustomGridLine YIntercept="{Binding DataContext.Data.Meta, ElementName = LayoutRoot}" Visibility="Visible" Stroke="GreenYellow" StrokeThickness ="4"/> </telerik:ChartArea.Annotations> <telerik:ChartArea.AxisX> <telerik:AxisX AutoRange="True" MajorGridLinesVisibility="Visible" StripLinesVisibility="Collapsed" MinorTicksVisibility="Collapsed" AxisLabelsVisibility="{Binding IsFirst}"> <telerik:AxisX.AxisStyles> <telerik:AxisStyles> <telerik:AxisStyles.ItemLabelStyle> <Style TargetType="TextBlock"> <Setter Property="Visibility" Value="Collapsed"></Setter> </Style> </telerik:AxisStyles.ItemLabelStyle> <telerik:AxisStyles.TickLineStyle> <Style TargetType="Line"> <Setter Property="Visibility" Value="Collapsed"></Setter> </Style> </telerik:AxisStyles.TickLineStyle> </telerik:AxisStyles> </telerik:AxisX.AxisStyles> </telerik:AxisX> </telerik:ChartArea.AxisX> <telerik:ChartArea.AxisY> <telerik:AxisY StripLinesVisibility="Collapsed" MajorGridLinesVisibility="Visible" MinorTicksVisibility="Collapsed" AutoRange="{Binding DataContext.Data.Y_AxisAuto, ElementName=LayoutRoot}" MinValue="{Binding DataContext.Data.Y_MinAxisValue, ElementName=LayoutRoot}" MaxValue="{Binding DataContext.Data.Y_MaxAxisValue, ElementName=LayoutRoot}" Step="{Binding DataContext.Data.Y_StepAxisValue, ElementName=LayoutRoot}"> <!--AutoRange="False" Step="10" MinValue="50" MaxValue="100"--> <telerik:AxisY.AxisStyles> <telerik:AxisStyles ItemLabelStyle="{StaticResource AxisRightStyle}" /> </telerik:AxisY.AxisStyles> </telerik:AxisY> </telerik:ChartArea.AxisY> </telerik:ChartArea> </telerik:ChartDefaultView.ChartArea> </telerik:ChartDefaultView> </Controls:RadChart.DefaultView> </Controls:RadChart> <StackPanel Background="#FF1C2640" Margin="0,10,0,5" Grid.Column="1"> <TextBlock Height="24" TextWrapping="Wrap" Text="{Binding Serie}" FontFamily="Arial Unicode MS" FontSize="14.667" Foreground="White" Margin="0" TextAlignment="Center" /> </StackPanel> </Grid> </DataTemplate> <ItemsPanelTemplate x:Key="ItemsPanelTemplate"> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> <DataTemplate x:Key="SeriesNameItem"> <Grid Width="96" HorizontalAlignment="Left" Margin="0,15,0,0"> <TextBlock TextWrapping="Wrap" Text="{Binding PlainData.Serie}" HorizontalAlignment="Left" Width="96"/> </Grid> </DataTemplate> <ItemsPanelTemplate x:Key="SeriesNameDataTemplate"> <Grid> </Grid> </ItemsPanelTemplate> <DataTemplate x:Key="DataTemplateTitles"> <Grid Background="#FF3F0606"> <TextBlock Margin="0" TextWrapping="Wrap" Text="{Binding}" Foreground="#FFAD2B2B" Width="200"/> </Grid> </DataTemplate> <ItemsPanelTemplate x:Key="ItemsPanelTemplate1"> <StackPanel/> </ItemsPanelTemplate> <!--<ControlTemplate x:Key="ItemsControlControlTemplate1" TargetType="ItemsControl"> <ItemsPresenter VerticalAlignment="Top"/> </ControlTemplate>--> </ResourceDictionary> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="Transparent"> <ScrollViewer x:Name="scroll" BorderThickness="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="0" > <Grid x:Name="Main" Background="White"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" MinWidth="90"/> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid x:Name="Aux" Grid.Column="0" Grid.Row="0" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="45" /> <RowDefinition Height="*" /> <RowDefinition Height="36" /> </Grid.RowDefinitions> <Grid x:Name="Titles" Grid.Row="1" UseLayoutRounding="False" Margin="0, 0, 0, 0" /> </Grid> <ItemsControl x:Name="ItemControl" Grid.Column="1" Grid.Row="0" ItemsSource="{Binding PlainData}" ItemTemplate="{StaticResource DataTemplate}" ItemsPanel="{StaticResource ItemsPanelTemplate}" Margin="0,0,0,0" BorderBrush="#FF6B5BE0" BorderThickness="1" Background="Yellow"/> </Grid> </ScrollViewer> </Grid></UserControl>****MAinPage.xaml.CS****
using System;using System.Windows.Media;using System.Windows.Controls;using System.ComponentModel;using System.Collections.Generic;using System.Collections.ObjectModel;namespace SoEmptyApp{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } } public class pruebaVM : INotifyPropertyChanged { public pruebaVM() { } private ObservableCollection<SubGraficoInfInd> m_PlainData; public ObservableCollection<SubGraficoInfInd> PlainData { get { return m_PlainData; } set { if (m_PlainData != value) { m_PlainData = value; ThrowPropertyChanged("PlainData"); } } } private ObservableCollection<string> m_SeriesNames; public ObservableCollection<string> SeriesNames { get { return m_SeriesNames; } set { m_SeriesNames = value; ThrowPropertyChanged("SeriesNames"); } } public void ThrowPropertyChanged(string prmPropertyName) { PropertyChangedEventHandler oHandler = PropertyChanged; PropertyChangedEventArgs e = new PropertyChangedEventArgs(prmPropertyName); if (oHandler != null) oHandler.Invoke(this, e); } public event PropertyChangedEventHandler PropertyChanged; } public class SubGraficoInfInd : List<SerieModel> { public SubGraficoInfInd() { } public SubGraficoInfInd(int prmCont) : base(prmCont) { } private string m_Serie; public string Serie { get { return m_Serie; } set { m_Serie = value; ThrowPropertyChanged("Serie"); } } public void ThrowPropertyChanged(string prmPropertyName) { PropertyChangedEventHandler oHandler = PropertyChanged; PropertyChangedEventArgs e = new PropertyChangedEventArgs(prmPropertyName); if (oHandler != null) oHandler.Invoke(this, e); } public event PropertyChangedEventHandler PropertyChanged; } public class SerieModel : INotifyPropertyChanged { private string m_Category; //Nombre o Categoria de la Serie private double m_XValue; //Valor de la abscisa X private double m_YValue; //Valor de la abscisa Y private Brush m_Color; //Color almacenado como string //Constructor Default public SerieModel() { } //Constructor con 3 parámetros public SerieModel(string prmCategory, double prmYValue, Brush prmColor) { Category = prmCategory; YValue = prmYValue; Color = prmColor; } public string Category { get { return m_Category; } set { m_Category = value; ThrowPropertyChanged("Category"); } } public double XValue { get { return m_XValue; } set { m_XValue = value; ThrowPropertyChanged("XValue"); } } public double YValue { get { return m_YValue; } set { m_YValue = value; ThrowPropertyChanged("YValue"); } } public Brush Color { get { return m_Color; } set { m_Color = value; ThrowPropertyChanged("Color"); } } public void ThrowPropertyChanged(string prmPropertyName) { PropertyChangedEventHandler oHandler = PropertyChanged; PropertyChangedEventArgs e = new PropertyChangedEventArgs(prmPropertyName); if (oHandler != null) oHandler.Invoke(this, e); } public event PropertyChangedEventHandler PropertyChanged; }}***Graphic to Print View***
<UserControl x:Class="SoEmptyApp.PrintGraphic" mc:Ignorable="d" d:DesignHeight="404" d:DesignWidth="514"> <Grid x:Name="LayoutRoot" Background="White" Height="392" Width="508"> <Button Content="Button" Height="25" HorizontalAlignment="Left" Margin="43,40,0,0" Name="button1" Width="86" VerticalAlignment="Top" Click="button1_Click" /> <Border BorderBrush="Silver" DataContext="{Binding Data}" Child="{Binding Visual}" BorderThickness="1" Height="300" Width="484" HorizontalAlignment="Left" Margin="12,80,0,0" Name="border1" VerticalAlignment="Top" /> </Grid></UserControl>***Graphic to print.xaml.CS*****
using System;using System.Windows;using System.Windows.Media;using System.Windows.Controls;using System.Windows.Printing;using System.Collections.Generic;using System.Collections.ObjectModel;namespace SoEmptyApp{ public partial class PrintGraphic : UserControl { List<UIElement> oGraficos = new List<UIElement>(); pruebaVM vm; public PrintGraphic() { InitializeComponent(); MainPage oMainPage = new MainPage(); vm = new pruebaVM(); ObservableCollection<SubGraficoInfInd> PlainData = new ObservableCollection<SubGraficoInfInd>(); //Nro de Columnas int iItemsCount = 2; string[] sSerieNames = new string[2] { "Satisfaccion Total", "Insatisfaccion Total" }; SubGraficoInfInd[] m_oSaveData = new SubGraficoInfInd[iItemsCount]; SubGraficoInfInd[] m_oModelList = new SubGraficoInfInd[iItemsCount]; for (int iKeyI = 0; iKeyI < iItemsCount; iKeyI++) { m_oSaveData[iKeyI] = new SubGraficoInfInd(iItemsCount); m_oSaveData[iKeyI].Serie = sSerieNames[iKeyI]; //Nro de Series por grafico int iMaxIterator = 6; int iKeyJ = 0; while (iKeyJ < iMaxIterator) { try { m_oSaveData[iKeyI].Insert(0, new SerieModel("Transylvania", 456.23, CreateBrushes("#FF22366D"))); } catch { } iKeyJ++; } m_oModelList[iKeyI] = new SubGraficoInfInd(iItemsCount); m_oModelList[iKeyI].Serie = sSerieNames[iKeyI]; foreach (SerieModel oGraph in m_oSaveData[iKeyI]) { m_oModelList[iKeyI].Add(oGraph); } PlainData.Add(m_oModelList[iKeyI]); } vm.PlainData = PlainData; oMainPage.DataContext = vm; oGraficos.Add(oMainPage); } public SolidColorBrush CreateBrushes(string prmColor) { SolidColorBrush _Result = new SolidColorBrush(); try { _Result = new SolidColorBrush(GetColor(prmColor)); } catch { _Result = new SolidColorBrush(); } return _Result; } public Color GetColor(string prmHexColor) { Color _Result = new Color(); try { prmHexColor = prmHexColor.Replace("#", string.Empty); byte a = Convert.ToByte(prmHexColor.Substring(0, 2), 16); byte r = Convert.ToByte(prmHexColor.Substring(2, 2), 16); byte g = Convert.ToByte(prmHexColor.Substring(4, 2), 16); byte b = Convert.ToByte(prmHexColor.Substring(6, 2), 16); _Result = Color.FromArgb(a, r, g, b); } catch { _Result = new Color(); } return _Result; } private void button1_Click(object sender, RoutedEventArgs e) { int iItemIndex = 0; PrintDocument doc = new PrintDocument(); doc.PrintPage += (se, ep) => { StackPanel oItemHost = new StackPanel(); while (iItemIndex < oGraficos.Count) { oItemHost.Children.Add(oGraficos[iItemIndex]); oItemHost.Measure(new Size(ep.PrintableArea.Width, double.PositiveInfinity)); if (oItemHost.DesiredSize.Height > ep.PrintableArea.Height && oItemHost.Children.Count > 1) { oItemHost.Children.Remove(oGraficos[iItemIndex]); ep.HasMorePages = true; break; } iItemIndex += 1; ep.PageVisual = oItemHost; } }; doc.Print("Test"); } }}