Have a ShellListView following a ShellTreeView Display Additional Shell Objects

Shell for WPF Forum

Posted 4 years ago by Elem
Version: 20.1.0

Hi, and thanks for your time.

At its core, what I want to do is have the ShellListView work the same way the default RootSpecialFolderKind="Computer" works, where files are displayed in the ShellListView and just file structure is displayed in ShellTreeListBox but they still are linked.

I have tried several ways of doing this. Right now I have two seperate Custom Shells defined. The ShellTreeListBox gets the one that only shows folders. The ShellListView gets the one that has both files and folders. I am trying to bind the ShellListView to the ShellTreeListBox via its "Currently Selected Path", but I am having trouble finding out what that variable is and how to bind to it properly. Ive also tried selected item with limited success.

I was thinking since the computer file explorer does this by default, there might just be an option to set it up somewhere? Is there some better way to do this? I feel like its probably a common requirement. If not, what is the variable I would bind too in ShellTreeListBox to get its currently selected path.

Appreciate any help

[Modified 4 years ago]

Comments (4)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA


If you take a look at our File Explorer demo, you'll see how we implemented this kind of setup for the Windows shell. 

All we do is set the ShellTreeListBox.RootSpecialFolderKind, but you could use another property to set the root folder too.  Then the XAML Binding on ShellListView takes care of the rest, where it tells the ShellListView to show the contents of the selected IShellObject in the ShellTreeListBox:

<shell:ShellTreeListBox x:Name="treeListBox" RootSpecialFolderKind="Default" />
<shell:ShellListView x:Name="listView" RootShellFolder="{Binding ElementName=treeListBox, Path=SelectedShellObject}" />

ShellTreeListBox will not show files by default whereas ShellTreeListView will.

Actipro Software Support

Posted 4 years ago by Elem

Thanks for your answer! It seems I may have been to general about some details of my issue though. My apologise.

I am working in the File Explorer Demo (Its a very nice demo) and I am adding a custom ftp folder shell to the heirarchy. The behaviour you mentioned works exactly as you say for the part of the application that shows files on the computer via RootSpecialFolderKind.

The problem I need to overcome is I need that same behaviour for the custom FTP shell folder I have created. It is connected to an FTP service and has both file and folder access. Both files and folders are appearing. However because ShellTreeListView is bound to the same ShellObject as ShellTreeListBox, I am having files displayed in both.

Ive been digging through your documentation for a while now, and I saw that ShellObjects have these properties:

        // Summary:
        //     Gets whether the shell object is a folder, which is anything that can contain
        //     other shell objects.
        // Value:
        //     true if the shell object is a folder, which is anything that can contain other
        //     shell objects; otherwise, false. The default implementation of this property
        //     returns true based on an applicable ActiproSoftware.Shell.ShellObjectBase.Kind
        //     property value.
        public virtual bool IsFolder { get; }

It is always set to true for my custom shell object. Is this what controls if the files appear in ShellTreeListBox? I havent found anything stating yes or no to that.

I have also come across in your documentation the ShellObjectWrapper class. Is that the tool to use to accomplish this? Based on the demo having example folders without using ShellObjectWrapper, I am not sure.

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Elem,

Even if you have a custom FTP shell service, the same general concept should work like it does for our default Windows implementation.

Yes the IShellObject.IsFolder property determines if the object is considered a folder or file.  So if you are always returning true for that, then that would definitely be a problem.  Your custom shell objects should return false for files.  That would probably solve your problem.

Our default implementation of ShellObjectBase.IsFolder looks at the Kind property.  The folder or library kinds all return true for IsFolder.  If your shell object says its Kind is a File, then it will be considered a file.  I'd recommend you set the Kind appropriately for your custom shell objects.

ShellObjectWrapper is more for wrapping and customizing an IShellObject that you don't have the source for.  Such as if you want to special case and alter how one of our Windows shell objects behaves.

[Modified 4 years ago]

Actipro Software Support

Posted 4 years ago by Elem

Thanks for your help!

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.