Have a ShellListView following a ShellTreeView Display Additional Shell Objects

Shell for WPF Forum

Posted 8 days ago by Elem
Version: 20.1.0
Avatar

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 7 days ago]

Comments (4)

The latest build of this product (v2020.1.1) was released 7 days ago, which was before the next post in this thread.
Posted 7 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

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 7 days ago by Elem
Avatar

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 7 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

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 7 days ago]


Actipro Software Support

Posted 7 days ago by Elem
Avatar

Thanks for your help!

Add Comment

Please log in to a validated account to post comments.