How to make newly added document active?

I'm binding a ObservableCollection<UIElement> named Docs to my DocumentContainer's ItemsSource property in my viewmodel. When I add new docs it worked fine, new tabs get created, except that, new tabs are added to the background, and I want to bring the newly created tab to the foreground.

So far, I tried :

1. to set the ActiveDocument property

2. DocuemntContainer.SelectItem(newItem)

but none of these works for me.

So I'm asking for your help, how can I bring newly created tab to the forground?


3 Replies

SN Sudharsan Narayanan Syncfusion Team October 18, 2021 03:34 AM UTC

Hi Carlos,

Thanks for contacting Syncfusion support,

Our WPF Docking Manager and Document Container are not Items Control. So, it is not possible to have a traditional Items Source binding to a collection of objects in the View Model. However, this can be achieved by creating wrapper or adapter for the DockingManager.

Could you please refer the below blog link to achieve the MVVM pattern in DockingManager.

http://www.syncfusion.com/blogs/post/MVVM-Adapter-for-WPF-Docking-Manager.aspx  
 

Please download the Docking Adapter sample from the below link:

Sample: https://github.com/SyncfusionExamples/working-with-wpf-docking-manager-and-mvvm  
 

We cannot set Item Template directly, but we can apply Item Template to child based on its Datatype in App.xaml file. You can find the same from the sample.


Regards,
Sudharsan
 



CA Carlos October 18, 2021 10:05 PM UTC

Thank you for the replay. I finally figured out what's wrong.


I'm using catel eventToCommand binding on my usercontrol to a doubleclick event to send a message to the shell view of my app. In the shellviewmodel, there's a message subscriber method that do the tab creation.


After I set the event.Handled = true; on the usercontrol before I send the message, the tab behavior went as expected. I think it's the event handling that got in the way. Hope this is helpful to fellows using this kind of event to command binding.



SN Sudharsan Narayanan Syncfusion Team October 19, 2021 07:08 AM UTC

Hi Carlos,

We are glad to know that the reported problem has been resolved at your end. Please let us know if you need any further assistance. Always, we will be happy to assist you. 

Regards,
Sudharsan


Loader.
Up arrow icon