How to clone a visual Silverlight tree structure

I have the same problem as the question mentioned in Printing in Silverlight 4. "

To get around this problem, I tried to scale the transform root of my visual tree before printing.

    void document_PrintPage(object sender, PrintPageEventArgs e)
    {
        var renderScale = 1.0D;
        if (LayoutRoot.ActualWidth > e.PrintableArea.Width)
            renderScale = e.PrintableArea.Width/LayoutRoot.ActualWidth;

        var scaleTransform = new ScaleTransform();
        scaleTransform.ScaleX *= renderScale;
        scaleTransform.ScaleY *= renderScale;

        e.PageVisual = LayoutRoot;
        e.PageVisual.RenderTransform = scaleTransform;
    }

Now Silverlight visual images overlaid on a piece of paper correctly print over the code.

Now the problem is that itself is LayoutRootnow scaled down on the screen.

The question is, is there a way to create a clone LayoutRootbefore applying scaling?

My walk is to apply scale transformation again after printing, but I would like to know if there is a way to clone the visual tree

+1
2

, . , ( ) , , . ScaleTransform , , .

"work around", myContainer.ClearValue(FrameworkElement.RenderTransformProperty) EndPrint. ( ..).

+1

Silverlight.

xamlreader/writer xaml .

ex

xaml originalbutton, , readerLoadButton

// Save the Button to a string.
string savedButton = XamlWriter.Save(originalButton);

// Load the button
StringReader stringReader = new StringReader(savedButton);
XmlReader xmlReader = XmlReader.Create(stringReader);
Button readerLoadButton = (Button)XamlReader.Load(xmlReader);
0

Source: https://habr.com/ru/post/1743526/


All Articles