Quantcast
Channel: Cloning UI elements.
Viewing all articles
Browse latest Browse all 2

Cloning UI elements.

0
0
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

Latest Images

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Vimeo 10.6.2 by Vimeo.com, Inc.

Vimeo 10.6.2 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.0 by Vimeo.com, Inc.

Vimeo 10.6.0 by Vimeo.com, Inc.

Re:

Re:





Latest Images

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.1 by Vimeo.com, Inc.

Vimeo 10.6.0 by Vimeo.com, Inc.

Vimeo 10.6.0 by Vimeo.com, Inc.

Re:

Re:

Re:

Re: