Need a way to set the SelectedIndex while using DocumentItemsSource

Docking/MDI for WPF Forum

Posted 7 years ago by Vikas Rao - Software Design Engineer, Tektronix
Version: 11.2.0551
Avatar

I have added the docking windows in our app similar to the "MVVM features" sample. I need a way to set the selected document and choose one of the documents based on some event. However I could not find any property in DockSite or TabbedMdiHost that does this.

Basically I am looking at a property like SelectedIndex which is present in TabbedMdiContainer.

Comments (4)

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

Hi Vikas,

We don't currently have a property like that, as there can be any number of "selected" windows. Our DockSite does have an ActiveWindow that  tracks the window with focus, but that is not the same thing.

Assuming that's what you mean, then you would have to manually sync that with your view model using the WindowActivated/WindowDeactivated events, and by calling Activate on an associated DockingWindow as needed.


Actipro Software Support

Posted 7 years ago by Vikas Rao - Software Design Engineer, Tektronix
Avatar

The active funnction may help. However I am not sure how I can get hold the docking window that I want to Activate.

Let me present my problem in a different way. I am using docksite to add three docking windows through MVVM. I have events in my app that get invoked based on Keyboard shortcut pressed. So If I am able to get to the collection of Docking windows I can then call Activate on one of them based on the shortcut. However I do not see a way to get it.

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

Hi Vikas,

You can find the list of documents in the DockSite.DocumentWindows collection. You can use the DocumentWindow.IsContainerForItem property to determine if the given DocumentWindow was created to present your view model (i.e. the item in the DocumentItemsSource collection), then check the DocumentWindow.DataContext to get the actual view model.

Or you can use the DockSite.ContainerFromDocumentItem to get the DockingWindow associated with your view model, if you have a reference to the view model.


Actipro Software Support

Posted 7 years ago by Vikas Rao - Software Design Engineer, Tektronix
Avatar

Yes that helped. Thanks!...

The latest build of this product (v2019.1 build 0681) 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.