I have been searching up and down the web and unfortunately never came across an issue quite like mine, so here goes:
My C# WPF application won\'t show me no OpenFil
Not sure if you figured it out or not, but I recently had this same problem. In my case, the problem was that my application hadn't established an existing window.
My code looked something like this.
private void Application_Startup(object sender, StartupEventArgs e) {
string startupFileName = String.Empty();
if ( startupMode = StartupMode.Load ) {
// open existing file
OpenFileDialog openDlg = new OpenFileDialog();
if (openDlg.ShowDialog() != true)
return;
startupFileName = openDlg.FileName;
} else {
// create a new file
SaveFileDialog saveDlg = new SaveFileDialog();
if (saveDlg.ShowDialog() != true)
return;
startupFileName = saveDlg.FileName;
}
// show my main application window
MainWindow myMainWindow = new MainWindow(startupFileName);
myMainWindow.Show();
}
The OpenFileDialog (or SaveFileDialog) would immediately return false without showing because my application had no window for it to attach itself to.
My solution was to put the open/save code after I created my main window but before I called the Show() method.