OpenDialog for WPF
Asked Answered
E

1

24

I just started with WPF. Moved from Window Form.

Where do those openDialog, saveDialog gone? And a bunch of stuff.

Exorcise answered 27/8, 2009 at 8:55 Comment(1)
Here's the answer to the second question ("And a bunch of stuff"): stackoverflow.com/questions/tagged/wpfSchonfield
V
27

Look in Microsoft.Win32 namespace

OpenFileDialog openDialog = new OpenFileDialog();
if (openDialog.ShowDialog().Value)
{
      ..........
}

And the same for SaveFileDialog

SaveFileDialog saveDialog = new SaveFileDialog();
if (saveDialog.ShowDialog().Value)
{
      ..........
}
Villalobos answered 27/8, 2009 at 9:1 Comment(3)
These are hard to set up, in the old Window Form there is easy options, anyway thanks.Exorcise
Are you sure that the openDialog or the saveDialog always return a value? Otherwise you'll get a NullReferenceException.Claver
At firs OpenFileDialog should return instance or fail with exception, it is not good practice to check null in this case because you will lost info about exceptionVillalobos

© 2022 - 2024 — McMap. All rights reserved.