在 Silverlight 中打印。部分页面缺失

Printing In Silverlight. Some pages missing

我正在维护一个从 silverlight 打印支票的旧应用程序。 支票位于网格中,用户选择它们并按下打印按钮。 我确认在网格中选择的所有支票都已发送到打印机,但我注意到有时在实际打印输出中会丢失一些支票。我什至检查了 EndPrint 是否有错误,并且有 none。 我怎样才能确保所有数据都得到实际打印?

这是打印页面事件的代码

StackPanel stackPanel = new StackPanel();
CheckInfo check = selectedChecks[printItemIndex];
PrintCheck printCheck = BuildPrintCheck(check);
stackPanel.Children.Add(printCheck);
stackPanel.Measure(new Size(args.PrintableArea.Width, double.PositiveInfinity));
if (++printItemIndex < selectedChecks.Count) 
       args.HasMorePages = true;

args.PageVisual = stackPanel;

我在此处找到了此问题的解决方法 http://www.thomasclaudiushuber.com/blog/2009/11/25/how-to-print-dynamically-created-images-in-silverlight-4-beta/

基本上不是直接将图像放入页面,而是放置一个矩形,然后在 运行 时动态加载图像,将其设置为图像画笔的图像源,然后设置填充 属性 到图像画笔的矩形。

好的,事实证明 SilverLight5(运行时)在打印图像时存在问题。客户端 运行 SilverLight4 上不存在该问题。 这是我在代码中修复它的方法

    private void PlaceImages()
        {

            var logoStreamResourceInfo = Application.GetResourceStream(new Uri("myApp;/Images/logo.png", UriKind.Relative));
            var logo = new BitmapImage();
            logo.SetSource(logoStreamResourceInfo.Stream);
            var logoImageBrush = new ImageBrush();
            logoImageBrush.ImageSource = logo;
            upperLogo.Fill = logoImageBrush;
            lowerLogo.Fill = logoImageBrush;

        }