Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecified element is already the logical child of another element. Disconnect it first Printing multiple pages from user control
    text
    copied!<p>The visual <code>v</code> is part of a grid section within a user control that I ma trying to print. I am new to c# and am not entirely sure why I am getting this error. Could this be related to the xaml code? </p> <pre><code>private void Print( Visual v ) { var pd = new PrintDialog(); var document = new FixedDocument(); var fixedPage = new FixedPage(); //System.Windows.FrameworkElement e = v as System.Windows.FrameworkElement; //if( e == null ) Transform originalScale = fixedPage.LayoutTransform; //get selected printer capabilities System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities( pd.PrintTicket ); System.Windows.Size sz = new System.Windows.Size( capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight ); fixedPage.Width = sz.Width; fixedPage.Height = sz.Height; // Add visual, measure/arrange page. fixedPage.Children.Add((FrameworkElement)v); fixedPage.Measure(sz); fixedPage.LayoutTransform = new ScaleTransform( 0.2823293807641634 + 0.2498215560314061, 0.2823293807641634 + 0.2498215560314061 ); fixedPage.Arrange( new System.Windows.Rect( new System.Windows.Point( capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight ), sz ) ); fixedPage.UpdateLayout(); fixedPage.LayoutTransform = originalScale; //var pageContent = new PageContent(); //((IAddChild)pageContent).AddChild(internalPage); //document.Pages.Add(pageContent); pd.PrintDocument(document.DocumentPaginator, "My Document"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload