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

Cloning UI elements.

$
0
0
There's no real good way to clone a UI element. Serializing and deserializing XAML is one way to go, but quite costly and not necessarily as straightforward.

Honestly though I don't think you're proposed solution actually solves the problem very well anyway. Even though WPF makes it really easy to print the actual UI elements, it's really not the best solution. The print medium is vastly different than the screen. You should really translate the data into a format that better suits the print medium if you want to give the best printing experience to your users. This usually means creating a FlowDocument and converting the data that is to be printed into elements in the System.Windows.Document namespace. Specifically using a Table for large lists of data. If you took this approach you most certainly could do it all off on another thread. Good example of building a FlowDocument with a Table here in the SDK.

That said if you wanted to continue pursuing your current approach, I would recommend simply making sure you define the appearance of your ListView with a Style. In the "live" UI you would put a ListView and bind the data to it and it would look great and whatnot. Then when you're ready to do the printing, instantiate a new ListView on the printing thread, give it the same style and then bind the same data to it.

Cheers,
Drew

P.S. BTW, you'll need to make sure to setup a new Dispatcher on that printing thread if you're not already doing it. More on that here in the SDK...

Viewing all articles
Browse latest Browse all 2


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>