Quantcast
Viewing all articles
Browse latest Browse all 2

Cloning UI elements.

Hi,

What I am trying to do is print a large list view, to get all the elements to be visible i set the measure and arrange methods to be the desired size for the listview.  This triggers an update so that it re-renders all rows, even ones that are currently not visible.  Then I dump that UIElement to a RenderTargetBitmap.  Now this resizing and re-rendering can take a while on a large list so I decided to to do this on a separate thread.

So now my actual printing logic and such is in a separate thread, but the scaling and resizing of the listview is still on the main thread which blocks and can take a little while to complete.  What I want is essentially to pass a copy of the listview to the print logic so that it can be resized and such in the background thread and then after printing discard it.

The copy is not for user interaction, will never be seen by the user, it will directly go to the printer. 

So whats the best way to clone essentially part of a visual tree? Is this possible or do I need to essentially make a completely new list?

I was trying to use the XamlWriter/Reader to read in the listview and then load it as another UIElement but it is failing  on me.  I am getting stack overflow, possibly my listview is too nested for this approach?

Thanks for any advice.

This is my current clone method

public static UIElement cloneElement(UIElement orig) 
        { 
            if (orig == null) 
                return (null); 
 
            string s = XamlWriter.Save(orig); 
            StringReader stringReader = new StringReader(s); 
            XmlReader xmlReader = XmlTextReader.Create(stringReader, new XmlReaderSettings()); 
            return (UIElement)XamlReader.Load(xmlReader); 
        } 


Viewing all articles
Browse latest Browse all 2

Trending Articles


Vimeo 10.7.1 by Vimeo.com, Inc.


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


FORECLOSURE OF REAL ESTATE MORTGAGE


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


Pamatay na Banat and Mga Patama Love Quotes