New to Telerik UI for WPF? Download free 30-day trial

Commands

The file dialogs suite provides several commands used to interact with the controls. All commands can be found in the FileDialogsCommands static class. The commands are attached to the controls' operations as copy, cut, open folder/file, delete, etc.

If you use the ExplorerControl it might be useful to execute the commands manually in some cases. To do so, you can call the Execute() method of the corresponding ICommand implementation. Alternatively, you can set the command to the Command property of a button or a similar component.

All commands in the FileDialogsCommands class are objects of type RoutedUICommand.

Example 1: Executing a command in code

RoutedUICommand command = (RoutedUICommand)FileDialogsCommands.Delete; 
command.Execute(this.explorerControl, this.explorerControl); 

Example 2: Assigning a command to a Button in XAML

<Grid> 
    <fileDialogs:ExplorerControl x:Name="explorerControl"/> 
    <Button Command="fileDialogs:FileDialogsCommands.Delete" 
            CommandParameter="{Binding ElementName=explorerControl}" 
            CommandTarget="{Binding ElementName=explorerControl}" 
            Content="Delete"/> 
</Grid> 

List of Commands

  • NewFolder Command: This command creates a new folder in the current directory. It is executed when you press the New Folder Button or call the command manually as shown in Examples 1 and 2.

  • Edit Command: This command starts the edit mode of the selected file/folder. It is executed when you press F2 or call the command manually as shown in Examples 1 and 2.

  • Copy Command: This command copies a file/folder from the clipboard if available. It is executed when you press Ctrl+C or call the command manually as shown in Examples 1 and 2.

  • Cut Command: This command cuts the selected file/folder. It is executed when you press Ctrl+X or call the command manually as shown in Examples 1 and 2.

  • Paste Command: This command pastes a file/folder from the clipboard if available. It is executed when you press Ctrl+V or call the command manually as shown in Examples 1 and 2.

  • Delete Command: This command deletes the selected file/folder. It is executed when you press the Delete key or call the command manually as shown in Examples 1 and 2.

Most of those commands are also available in the context menu opened on right mouse click in the dialog control.

Cancel Keyboard Commands

To cancel the command executed for a specific key or a keycombo you can handle the PreviewKeyDown event of the dialog control.

Example 3: Canceling Delete command in ExplorerControl

private void ExplorerControl_PreviewKeyDown(object sender, KeyEventArgs args) 
{ 
    if (args.Key == Key.Delete) 
    { 
        args.Handled = true; 
    } 
} 

Example 4: Canceling Delete command in a dialog control

RadOpenFileDialog openFileDialog = new RadOpenFileDialog(); 
openFileDialog.Owner = this; 
openFileDialog.PreviewKeyDown += (s, args) => 
{ 
    if (args.Key == Key.Delete) 
    { 
        args.Handled = true; 
    } 
}; 
openFileDialog.ShowDialog(); 

See Also

In this article