Silverlight 打印繁忙\进度条 [英] Silverlight printing busy\progress bar

查看:39
本文介绍了Silverlight 打印繁忙\进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Silverlight 4 进行打印,但我想要某种进度条或忙碌指示器.

I'm using Silverlight 4 to print but I would like some sort of progress bar or busy indicator.

我曾尝试使用进度条,但它并没有真正起作用.我遇到的两个问题是:

I've tried to using a progress bar but it is not really working. The 2 issues I have are:

  • 进度条不指示进度,我有 IsIndeterminate=True,但在打印开始时它没有动画(单击打印"对话框的打印"按钮)
  • 进度条可见性未在适当的时间设置,这取决于我将代码设置为可见性的位置,它显示过早(单击打印之前)或过晚(打印工作一段时间后)

我猜,但我认为上述原因是因为当显示打印对话框时,Silverlight 已将控制权移交给操作系统进行打印(??).

I'm guessing, but I think the reason for the above is because when the print dialog is displayed Silverlight has handed off control to the OS for prining(??).

我尝试使用调度程序调用,但出现安全异常(只能通过用户单击显示对话框).

I tried using a dispatcher invoke but I get a security exception (dialog can only be displayed from user click).

关于如何处理上述任何一个问题的任何想法?

Any ideas on how to deal with either of the above issues?

谢谢.

推荐答案

在 XAML 中创建一个 BusyIndi​​cator,它是 Silverlight 工具包的一部分.然后在 BeginPrint 事件期间将 BusyIndi​​cator 的 IsBusy 设置为 True.同样在 EndPrint 期间,将 IsBusy 设置回 false.

Create a BusyIndicator in your XAML, it's a part of the Silverlight Toolkit. And then during the BeginPrint event set the BusyIndicator's IsBusy to True. Also during EndPrint set IsBusy back to false.

  var docToPrint = new PrintDocument();

        docToPrint.BeginPrint += (s, args) =>
            {
                MyBusyIndicator.IsBusy = true;
                MyBusyIndicator.BusyContent = "Printing...";
            };

        docToPrint.PrintPage += (s, args) =>
            {
             args.PageVisual = this.MainCanvas;                      
            };

        docToPrint.EndPrint += (s, args) =>
            {
                MyBusyIndicator.IsBusy = false;
                MyBusyIndicator.BusyContent = "";
            };

这篇关于Silverlight 打印繁忙\进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆