Sort Command?

Shell for WPF Forum

Posted 4 years ago by rex hui
Version: 19.1.0685
Avatar

We are implementing a popup menu similar to the Windows Explorer's "Sort by" popup under "View" where the user can choose the items being sorted by "Name", "Date modified", etc and also change the sort direction as well. 

I couldn't figure out how to achieve this. There isn't a Sort Command or a way I can sort the items by a specific column.

Comments (14)

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

Hi Rex,

It looks like we don't yet have a way to externally control sorting.  Internally ShellListView tracks a SortDirection (of type ColumnSortDirection)
and a SortByShellPropertyKey (of type Object).  The latter refers to an IShellProperty.Key value for one of the IShellProperty objects that is a column header.

How would you ideally like to see some of this exposed?  Would you like public SortDirection and SortByShellPropertyKey properties added that you could set?


Actipro Software Support

Posted 4 years ago by rex hui
Avatar

Thank you. I think that will be great!

I assume if I dynamically add/remove a column, I can use the SortByShellPropertyKey property to have the listview updated right?

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

Hi Rex,

We've added this update for the next build:

Added the ShellListView.SortDirection and SortShellPropertyKey properties, which determine how the list is sorted.

If you'd like to test a preview build, please write our support address and reference this thread.


Actipro Software Support

Posted 4 years ago by rex hui
Avatar

Thank you!

Posted 4 years ago by rex hui
Avatar

I have tried the Preview build and everything seems to be working so far. Thank you!

Posted 4 years ago by rex hui
Avatar

On the previous post, I said "I assume if I dynamically add/remove a column, I can use the SortByShellPropertyKey property to have the listview updated right?" That does not seem to be true.

Should you make the "RefreshColumn" of ShellListView public?

I was able to get it work by invoking it through reflection.

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

Hi Rex,

A sort should be occurring immediately when you change the SortShellPropertyKey property.  Can you give us some C# code that we can paste into our ShellListViewIntro QuickStart to see what you are seeing?


Actipro Software Support

Posted 4 years ago by rex hui
Avatar

A sort is being called but the WindowsShellService.CreateProperties is not and where else  can you update the columns other than from WindowsShellService.CreateProperties?

Just realized there is also the "CanColumnsToggleVisibility" inherited from TreeListView but that does not seem to work?

[Modified 4 years ago]

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

Hi Rex,

We are making the ShellListView.UpdateColumns method public in the next maintenance release, and also found the reason the columns weren't showing in the context menu when CanColumnsToggleVisibility was set.  That will be fixed as well.


Actipro Software Support

Posted 4 years ago by rex hui
Avatar

Thank you!

Posted 4 years ago by rex hui
Avatar

Hi,

I just ran into another issue. If the LayoutMode is set to MediumIcons (or anything other than Details), setting the SortShellPropertyKey or the SortDirection will generate an ArgumentException such as this:

Exception thrown: 'System.ArgumentException' in PresentationFramework.dll
An unhandled exception of type 'System.ArgumentException' occurred in PresentationFramework.dll
GeneratorPosition '12,1' passed to Remove does not have Offset equal to 0.

[Update]
I was able to fix this issue by setting the LayoutMode to Details before setting the SortShellPropertyKey or the SortDirection, and then restore the LayoutMode.

[Modified 4 years ago]

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

Hi Rex,

Thanks, I believe we found the problem here and fixed it for the next maintenance release.  Please write our support address and mention this thread if you'd like to get a preview build with the update to test with.


Actipro Software Support

Posted 4 years ago by rex hui
Avatar

Ok thanks!

Posted 4 years ago by rex hui
Avatar

The new build seems to be working well so far. thank you!

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.