This is a migrated thread and some comments may be shown as answers.

ExplorerControl - Restrict browsing to specific folder and its subfolders.

3 Answers 311 Views
FileDialogs
This is a migrated thread and some comments may be shown as answers.
Jared
Top achievements
Rank 1
Jared asked on 09 May 2019, 08:16 PM

Hello.

Our project has a requirement to show an ExplorerControl where navigation is limited to a user-defined folder and its subfolders.  Ideally, the navigation tree's root folder would be the specified folder (instead of the hierarchy from This PC to the target folder).

Is this functionality possible?

If there was a cancellable "OnBeforeNavigating" event to prevent navigating to parent folders, that might also be sufficient.

 

I've gotten close to it by handling the DirectoryRequesting event and cancelling any directories that are not the target folder, a parent folder, or child folder.

However, this still allows users to browse to parent folders and see the contents.  If I try to cancel the DirectoryRequesting events for the parent folders too, the control stops working.

We looked into editing the control template, but it proved to be more in-depth than we want to go.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 14 May 2019, 11:38 AM
Hello Jared,

There is no convenient event for you scenario. I've logged a feature request about this in the Telerik UI for WPF feedback portal where you can track its status. I also updated your Telerik points.

Currently, a possible approach that you can try is to show the available directories in the custom places area of the ExplorerControl. And hide the file browser tree control.
//FindChildByType<T> is an extension method part of Telerik.Windows.Controls namespace.
private void ExplorerControl_Loaded(object sender, RoutedEventArgs e)
{
    var explorerControl = (ExplorerControl)sender;
    var navigationTree = explorerControl.FindChildByType<FileBrowserTreeView>();
    navigationTree.Visibility = Visibility.Collapsed;
}
However, keep in mind that the breadcrumb part (where you enter the directory path) and the back button will still work.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Petar Mladenov
Telerik team
answered on 11 Dec 2019, 09:28 AM

Hello Jared,

I wanted to follow your up on this case. You can download this week's internal build and take advantage of the DirectoryNavigating event. To prevent navigation to folder of branch of folders, you can check the path in the event arguments and set e.Cancel true. If you also need some child folders of *non--navigable" folder not visible in the TreeView, you can use DIrectoryRequesting event. I would appreciate any feedback regarding these events and your scenario. Thank you in advance.

Regards,
Petar Mladenov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 31 Jan 2020, 04:17 PM
I've been using these.  They work well.  They also seem to speed up the loading of the dialog
Tags
FileDialogs
Asked by
Jared
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Petar Mladenov
Telerik team
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or