title: "Dialogs must be user-initiated." with SaveFileDialog in Silverlight 3
body: <p>I am working on a Silverlight 3 app with C#. I would like to allow the user to download an image from the Silverlight app. I am using SaveFileDialog to perform the file download task. The flow goes this way:</p>
  
  <ol>
  <li>User clicks on Download button in the SL app.  </li>
  <li>Web service call invoked to get the image from server  </li>
  <li>OnCompleted async event handler of the web method call get invoked and receives the binary image from the server  </li>
  <li>Within the OnCompleted event handler, SaveFileDialog prompted to user for saving the image to computer.  </li>
  <li>Stream the image to the file on user's harddrive.  </li>
  </ol>
  
  <p>I am using the following code in a function which is called from the OnCompleted event handler to accomplish SaveFileDialog prompt and then streaming to file.</p>
  
  <pre><code>            SaveFileDialog dialog = new SaveFileDialog();
              dialog.Filter = "JPG Files|*.jpg" + "|All Files|*.*";
              bool? dialogResult = dialog.ShowDialog();
  
              if (dialogResult == true)
              {
                  using (Stream fs = (Stream)dialog.OpenFile())
                  {
                      fs.Write(e.Result, 0, e.Result.Length);
                      fs.Close();
                  }
              }
  </code></pre>
  
  <p>The SaveFileDialog would throw the error "Dialogs must be user-initiated." when invoking ShowDialog method in the above code. What could i be missing here? How to overcome this?</p>