【问题标题】:System.InvalidOperationException: Specific element is already the logical child of another element. Disconnect is firstSystem.InvalidOperationException:特定元素已经是另一个元素的逻辑子元素。断开是第一
【发布时间】:2013-05-06 19:35:49
【问题描述】:

我正在尝试使用 Flow Document 打印一些段落和图像,如下面的代码所示

Paragraph invoiceID = new Paragraph(new Run("Invoice No : "+ txtInvoiceID.Text));
Paragraph qty001 = new Paragraph(new Run("Quantity : " + qtyText.Text));
Paragraph date001 = new Paragraph(new Run("Date : " +txtInvoiceDate.Text));

Section sec = new Section();
sec.Blocks.Add(invoiceID);
sec.Blocks.Add(qty001);
sec.Blocks.Add(date001);

FlowDocument fd = new FlowDocument();
PrintDialog pd = new PrintDialog();

fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWidth;
fd.PagePadding = new Thickness(50);
fd.ColumnWidth = pd.PrintableAreaWidth;
fd.Blocks.Add(sec);
fd.Blocks.Add(new BlockUIContainer(barCodeImage));

IDocumentPaginatorSource dps = fd;
pd.PrintDocument(dps.DocumentPaginator,"Desciption");

我知道图像已被进程锁定,但我如何才能解锁此图像??

请帮忙

谢谢

扎扎布

【问题讨论】:

  • 图片锁定与你标题中提出的问题无关。

标签: c# wpf process writablebitmap


【解决方案1】:

在 WPF 中,每个控件只能有一个父级,因为您已经在 xaml 中定义了 barCodeImage,它是某个容器的子级。 因此您可以将其从容器中删除或克隆图像

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2012-02-20
    • 2012-08-23
    • 2012-11-17
    • 2011-04-30
    • 1970-01-01
    相关资源
    最近更新 更多