Reputation: 11
In Windows Forms it seems there are precreated dialog boxes for opening and saving files. That is greyed out in the WPF toolbox. Is there an easy way to create such a dialog box using WPF?
Upvotes: 1
Views: 540
Reputation: 16119
Have a look at OOkii Dialogs, it's a free library that supports a large range of "standard" and custom dialogs designed for both Winforms and WPF.
Upvotes: 0
Reputation: 12119
Yes, but you have to add a reference to Microsoft.Win32
and use the OpenFileDialog
class which will initiate the same OS dialog you'd get from Winforms...
var ofdXlsDataSource = new OpenFileDialog
{
CheckPathExists = true,
CheckFileExists = true,
Multiselect = false,
Filter = "Excel documents (*.xlsx)|*.xlsx",
RestoreDirectory = true
};
if (ofdXlsDataSource.ShowDialog() == true)
{
...
}
Upvotes: 1