Sort order of open documents

Docking/MDI for WPF Forum

Posted 13 years ago by John Dunn
Version: 10.2.0532
Avatar
Is there a way to change the sorting order of the list of opened documents displayed in the OpenDocumentsMenu? Currently it appears to sort things alphabetically with using the default string sort ordering. The main issue with that is that numeric document titles don't sort as expected - instead of 'Page 1', 'Page 2', ... 'Page 10', 'Page 11' you get 'Page 1', 'Page 10', 'Page 11', 'Page 2'... If the list needs to be sorted it is probably more correct to use StrCmpLogicalW to do the comparison.

In my case I don't want the list to be sorted at all - I'd like the list to display in the order that the pages have been added. Is that possible? If they have to be sorted I'd like to be able to sort using StrCmpLogicalW.

Comments (3)

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

The DockSite control has an event, WindowContextMenu.

In a handler for this event, you can check to see that the DockingWindowContextMenuEventArgs.ContextMenuType is TabbedMdiContainerOverflowButton.

To actually perform the sort, you can access the DockingWindowContextMenuEventArgs.ContextMenu property to acquire the actual ContextMenu that will display. The Items collection contains the objects that you would need to sort.

Please let us know if you have further questions.


Actipro Software Support

Posted 13 years ago by John Dunn
Avatar
Sorry about resurrecting this but I've just started to look back into implementing this.

What I'd like to do is have the menu displayed in the same order that the document windows are currently in. This is the same behavior as IE and seems like a logical approach. I've hooked WindowContextMenu and am able to change the order of the ContextMenu. The issue is that I'm not sure how the determine what order the DocumentWindows are currently in. DockSite.DocumentWindows returns the order that the windows were created and not the order that the tabs are currently in. Is there a way to get the list of DocumentWindows in the order of the tabs?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

The original source (e.OriginalSource) of the event should be a TabbedMdiContainer, from that you can get the order from the Items collection. The items may contain "track" elements, which you'd need to ignore. So for each item you'd simply verify that it is a DockingWindow.


Actipro Software Support

The latest build of this product (v24.1.1) 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.