首页 > 代码库 > silverlight visifire控件图表制作——silverlight 后台方法打印

silverlight visifire控件图表制作——silverlight 后台方法打印

一、后台方法

1、添加引用:using System.Windows.Printing;

2、全局变量://定义图片和文本打印变量  PrintDocument printImage;

3、构造方法体里:

          //图片打印对象  
                printImage = new PrintDocument();
                //图片打印事件处理  
                printImage.PrintPage += new EventHandler<PrintPageEventArgs>(printImage_PrintPage);

4、委托:

     //确认打印后开始打印 
            private void printImage_PrintPage(object sender, PrintPageEventArgs e)
            {
            //确认打印,打印对象 
            e.PageVisual = this.gridVisifire;
           }

5、页面事件:

      private void btnPrint_Click(object sender, RoutedEventArgs e)
            {
                //启动打印图片,出现打印对话框  
                printImage.Print(sTNameClick);
            }

 

二、前台打印按钮

 <Button Content="打印"  Name="btnPrint" FontSize="13" Height="25" HorizontalAlignment="Left" Margin="650,12,0,0"  VerticalAlignment="Top" Width="75" Click="btnPrint_Click" />