DXOpenFolderDialogService Class
Represents a dialog box that allows end-users to specify folder names for one or more folders to open.
Namespace: DevExpress.Xpf.Dialogs
Assembly: DevExpress.Xpf.Dialogs.v24.2.dll
NuGet Package: DevExpress.Wpf.Dialogs
Declaration
public class DXOpenFolderDialogService :
FileDialogServiceBase,
IOpenFolderDialogService,
IOpenDialogServiceBase,
IFileDialogServiceBase
Remarks
The DXOpenFolderDialogService provides the standard open folder dialog functionality and supports DevExpress theming mechanism that allows your applications to look consistent.
The DXOpenFolderDialogService
enables users to browse, create, and select folders in the File System by using the DXOpenFileDialog dialog.
The DXOpenFolderDialogService
implements the IOpenFolderDialogService interface.
How to Use
To use the DXOpenFolderDialogService service, attach it to your View via the Interaction.Behaviors collection.
<UserControl x:Class="FolderBrowserDialogServiceSample.Views.FolderBrowserDialogView"
...
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxdlg="http://schemas.devexpress.com/winfx/2008/xaml/dialogs">
<dxmvvm:Interaction.Behaviors>
<dxdlg:DXOpenFolderDialogService />
</dxmvvm:Interaction.Behaviors>
...
</UserControl>
Then, access the attached service by using one of approaches described in Services in POCO objects or Services in ViewModelBase descendants topics and invoke its IOpenFolderDialogService.ShowDialog method to show the open folder dialog.
public class OpenFolderDialogViewModel {
public virtual string SelectedFolder { get; protected set; }
public void ShowDialog() {
IOpenFolderDialogService service = this.GetService<IOpenFolderDialogService>();
if (service.ShowDialog(null, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))) {
// The selected folder path
SelectedFolder = service.Folder.Path;
}
return;
}
}
To select a folder, a user should select an item and press the Open button. When the dialog box is closed and the ShowDialog returns true, the IOpenFolderDialogService.Folder is set to an IFolderInfo object that contains information about the selected folder.
If you want to provide the user the ability to select a file instead of a folder, use the DXOpenFileDialogService instead.