Back to Devexpress

DXOpenFolderDialogService Class

wpf-devexpress-dot-xpf-dot-dialogs-eb1a1fa1.md

latest5.1 KB
Original Source

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.2.dll

NuGet Package : DevExpress.Wpf.Dialogs

Declaration

csharp
public class DXOpenFolderDialogService :
    FileDialogServiceBase,
    IOpenFolderDialogService,
    IOpenDialogServiceBase,
    IFileDialogServiceBase
vb
Public Class DXOpenFolderDialogService
    Inherits FileDialogServiceBase
    Implements 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:

Run Demo

To use the DXOpenFolderDialogService service, attach the service to a View using the Interaction.Behaviors collection:

xaml
<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:

csharp
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;
    }
}
vb
Public Class OpenFolderDialogViewModel
    Public Overridable Property SelectedFolder As String

    Public Sub ShowDialog()
        Dim service As IOpenFolderDialogService = Me.GetService(Of IOpenFolderDialogService)()

        If service.ShowDialog(Nothing, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) Then
            ' The selected folder path
            SelectedFolder = service.Folder.Path
        End If

        Return
    End Sub
End Class

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

DXOpenFolderDialogService Members

DevExpress.Xpf.Dialogs Namespace