Save File Dialog boxes in VB WPF

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?

Answers


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)
{
    ...
}

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.


Need Your Help

Relational Database for Time Series Data

sql database relational

I am currently trying to design a database to house production test data. Each unit undergoes the same test sequence (12 tests), voltage, current, and temperature data is collected from many locat...