I am using Silverlight5 and I just need to save a file from my Application. When user clicks the save button, it should open the SaveFileDialog with a default name. Using the following code:

private void Button_Click(object sender, RoutedEventArgs e)
    {
        SaveFileDialog dialog = new SaveFileDialog
        {
            DefaultExt = "xls",
            Filter =
                String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", "xls", "Excel"
                              ),
            FilterIndex = 1,
            DefaultFileName = "Test", 

        };
        dialog.ShowDialog();
    }

But the problem is, when we are adding DefaultFileName property to SaveFileDialog, it will show automatically a confirmation message window. I need to customize the message in the MessageBox shown when open SaveFileDialog.

Hope some of you may come across this problem, please guide me to overcome this one.

Please find the image below

enter image description here

1

There are 1 best solutions below

1
On

You can't. This message is generated by the plugin native implementation, so if you want to override this message; you'd need to create your very own silverlight plugin :)

Proof (from reflection of System.Windows.dll)

// System.Windows.Controls.SaveFileDialog
private bool? ShowDialogInternal(Window owner)
{
    ...
    // call to native plugin API to show save dialog
    num = XcpImports.UI_GetSaveFileName(NativeHost.Current.RuntimeHost, ref this.m_dlgInfo, out dialogResult);
    if (NativeMethods.SUCCEEDED(num) && this.m_dlgInfo.lpstrFile != IntPtr.Zero && dialogResult == DialogResult.OK)
    {
      // if everything went ok, we have the handle to saved file
      ...
    }
    ...
}

That being said - this dialog can be shut off if you configure your browser to trust your app. Also check out this connect issue questioning the validity of this dialog:

https://connect.microsoft.com/VisualStudio/feedback/details/690502/savefiledialog-security-warning