I have an XBAP app, which shows some pictures, and my users would like to save some of them to disk. But my XBAP app runs in the partial trust mode, so it can't initiate SaveFileDialog
, not to mention it can't access the File System.
What's would be the Stack Overflow recommended way to save a pic to disk in this case?
I found a solution to my problem and I'm going to put this answer as a community wiki.
As expected, I wasn't able to access file system, show
SaveFileDialog
or save the image to the clipboard due to the partial-trust security limitations.So, I've created an .ashx handler on the site, from which my XBAP application is deployed, which receives a certain image id in the URL string, queries the image from the DB, and returns the image (
context.WriteBinary
) under the proper content header "image/jpeg".In my XBAP, instead of the
Image
control I've put theWebBrowser
control, provided with the proper URI (you might need a trick to bind the Source property). You can only specify an URI that is pointing to the site of origin of your XBAP app. It can be an absolute path, or it can use the special syntax includingpack://siteoforigin:,,
Voila, now the picture supports the standard browser context menu with "Save...", "Set as background" and all the other useful elements :-)