How can I create a file extension filter?

Shell for WPF Forum

Posted 3 years ago by JP Garza
Version: 19.1.0685
Avatar

I was wondering what is the best way to create a ShellTreeListBox DataFilter that filters file types/extensions. I would like to display only files that end on .sq or .txt

Thanks

Comments (3)

Answer - Posted 3 years ago by JP Garza
Avatar

This appears to work:

private IDataFilter _folderExplorerDataFilter = new PredicateFilter(i => 
{
    var shellObjectVM = (ShellObjectViewModel)i;
    var supportedFileTypes = new[] { ".sq", ".txt" };
    return (shellObjectVM.IsFolder) ? true : supportedFileTypes.Any(shellObjectVM.Name.EndsWith); 
});

[Modified 3 years ago]

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

Hi JP,

Yes predicate filters would work fine for that kind of thing.


Actipro Software Support

Posted 3 years ago by JP Garza
Avatar

Alright, thank you!

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

Add Comment

Please log in to a validated account to post comments.