I want to be able to let user download file just like he clicked web page URL. My application is MVVM and I can't handle Button_click the way it is necessary to go around security limitations with 'SaveFileDialog'

When I download file in IE9 it just shows this little download bar on a bottom. How do I mimic this type of behavior?

3 Answers
3

You should be able to get there if you can execute JavaScript as a result of clicking your Silverlight button. Once you can execute JavaScript, you can use normal browser downloading techniques, even benefiting directly from IE9's download manager.

I've had issues in the past trying to have Silverlight invoke a standard download prompt via JavaScript (as though a user navigated to the download URL) due to various browser security issues or quirky behaviour.

In the end, I gave up and used the HyperlinkButton which basically works as though the user clicked a hyperlink and, thus far, works consistently across all browsers/security that I've tested.

Definitely not the best answer, and like I said, essentially came from "giving up". I'd be interested to see a better method.

HyperlinkButton is the only method that works as far as I am aware. We have tried various methods, but have eventually settled on HyperlinkButton mainly due to its ability to handle pop-up blockers correctly. Microsoft recommends this method.