Skip to main content
All docs
V25.1
  • 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.v25.1.dll

    NuGet Package: DevExpress.Wpf.Dialogs

    Declaration

    public class DXOpenFolderDialogService :
        FileDialogServiceBase,
        IOpenFolderDialogService,
        IOpenDialogServiceBase,
        IFileDialogServiceBase

    Remarks

    The DXOpenFolderDialogService delivers the standard open folder dialog functionality and supports DevExpress theming mechanism that allows your WPF applications to look consistent.

    The DXOpenFolderDialogService implements the IOpenFolderDialogService interface. Users can use the DXOpenFileDialog dialog to browse, create, and select folders in the File System:

    Open Folder Dialog - WPF Controls, DevExpress

    Run Demo

    To use the DXOpenFolderDialogService service, attach the service to a View using 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>
    

    Access the attached service using one of approaches described in Services in POCO objects and Services in ViewModelBase descendants help topics. Call the 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.

    Tip

    Use the DXOpenFileDialogService to allow the user to open a file.

    Inheritance

    Show 13 items
    Object
    DispatcherObject
    DependencyObject
    Freezable
    Animatable
    DevExpress.Mvvm.UI.Interactivity.AttachableObjectBase
    DevExpress.Mvvm.UI.Interactivity.Behavior
    DevExpress.Mvvm.UI.Interactivity.Behavior<FrameworkElement>
    DevExpress.Mvvm.UI.ServiceBaseGeneric<FrameworkElement>
    ServiceBase
    DevExpress.Mvvm.UI.WindowAwareServiceBase
    DevExpress.Mvvm.UI.FileDialogServiceBase
    DXOpenFolderDialogService
    See Also