Saving image of a plot in Silverlight

Aug 3, 2012 at 9:50 AM

I'm trying to save my plot (lineseries with axes) to something that I can use elsewhere in my application without having to load an oxyplot element. For this I would like to export the plot to an image (preferable just a standard silverlight implementation for internal use).

What would be the best way to go about this?


Would it be possible to get a xaml path from the plot? as this is one of the easiest ways to store vector data in silverlight.

Aug 3, 2012 at 8:24 PM

Not sure if there's a new way to do this, but in our OSS project (MIT/X-11 license) we want to persist images of controls, with the additional option of printing.

Here's how we do that bit:

In Silverlight, WritableBitmap has a constructor overload that takes any UIElement, so you can...
1) create a WriteableBitmap using the UIElement overload
2) encode the bitmap to a .jpg (optional)
3) save the image
    a) if you want a user-specified location to save, you have to use an OpenFileDialog
    b) otherwise, you can save to isolated storage

Aug 6, 2012 at 3:33 PM

This looks good! Thank you! I think this will be very sufficient for my needs.

Aug 6, 2012 at 6:46 PM

Good to hear - my pleasure. :)

Aug 8, 2012 at 11:19 PM

Isn't this the same as issue

I will look at your solution later, thanks for sharing!