Remove New Folder in OpenFileDialog

1 Answer 18 Views
FileDialogs
Gonzalo
Top achievements
Rank 1
Gonzalo asked on 19 May 2021, 08:53 PM
How do I disable or remove the New Folder button in OpenFileDialog?

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 24 May 2021, 10:38 AM

Hi Gonzalo,

Thank you for your interest in our FileDialogs for WPF.

You can hide the new folder button by manually set its Visibility property to Collapsed. You can subscribe to the Loaded event of the RadOpenFileDialog. Then you can get the button using our ChildrenOfType<T>() extension method. Check the following code snippet.

private void ShowOpenFileDialog()
{
    RadOpenFileDialog openFileDialog = new RadOpenFileDialog
    {                
        InitialDirectory = @"C:\Temp\TestFileDialogs"
    };
    openFileDialog.Loaded += SaveFileDialog_Loaded;
    openFileDialog.ShowDialog();            
}

private void SaveFileDialog_Loaded(object sender, RoutedEventArgs e)
{
    var saveFileDialog = sender as RadOpenFileDialog;
    var button = saveFileDialog.ChildrenOfType<RadButton>().FirstOrDefault(x => x.Name == "NewFolderButton");
    button.Visibility = Visibility.Collapsed;
}

Regards,
Dinko
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
FileDialogs
Asked by
Gonzalo
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or