This question is locked. New answers and comments are not allowed.
I have created a UIElement in which my layout for "Reports - Receipt - Print".
The layout contains Binding and other controls.
When I Click the Button for print
It throws an exception "Element is already the child of another element.".
In this line ----> canvas.Children.Add(this.DRReceipt);
The layout contains Binding and other controls.
When I Click the Button for print
It throws an exception "Element is already the child of another element.".
In this line ----> canvas.Children.Add(this.DRReceipt);
<
StackPanel
x:Name
=
"DRReceipt"
>
...RadGriView with binding...
...Label...
...Images...
</
StackPanel
>
var doc = new PrintDocument();
var offsetY = 0d;
var totalHeight = 0d;
Canvas canvas = new Canvas();
canvas.Children.Add(this.DRReceipt);
doc.PrintPage += (s, d) =>
{
d.PageVisual = canvas;
if (totalHeight == 0)
{
totalHeight = canvas.DesiredSize.Height;
}
Canvas.SetTop(canvas, -offsetY);
offsetY += d.PrintableArea.Height;
d.HasMorePages = offsetY <= totalHeight;
};
doc.Print("DeliveryReceipt");