We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot set active tab no matter what i do

Hi All

Hoping you can help.

I'm trying to add a new ContentControl to the DockingManager.Children collection and whilst it works it never sets it as the active tab.  I've tried many variations looking on the site here and it just wont set as active.  Here are a few examples.

setting SetIsSelectedTab before adding

public void AddNewTab(UserControl uc, string header)
{
            ContentControl cc = new ContentControl();
            cc.Content = uc; //my user control

            DockingManager.SetHeader(cc, header);
            DockingManager.SetState(cc, DockState.Document);
            DockingManager.SetIsSelectedTab(cc, true);

            MasterContainer.Children.Add(cc);
}

-----------------------------------
Using the ActivateWindow (I've also used ActiveWindow property and set it to the object)

public void AddNewTab(UserControl uc, string header)
{
            int hashCode = uc.GetHashCode();
            string sHashCode = hashCode >= 0 ? hashCode.ToString() : (-hashCode).ToString(); //make positive     
            ContentControl cc = new ContentControl();
            cc.Content = uc; //my user control
            cc.Name = sHashCode;

            DockingManager.SetHeader(cc, header);
            DockingManager.SetState(cc, DockState.Document);

            MasterContainer.Children.Add(cc);
            MasterContainer.ActivateWindow(sHashCode);
}

----------------------------------

No matter what the new tab is created and i can select it manually but it is never activated / focused when added.  Does anyone have any ideas please, really stuck and I'm  new to WPF so this is all a learning curve, I'm sure I'm being an idiot somewhere :(

My XAML if needed is

   <Syncfusion:DockingManager x:Name="MasterContainer" 
                                   UseDocumentContainer="true"  />


5 Replies

MS Marimuthu Sivalingam Syncfusion Team August 9, 2017 12:00 PM UTC

Hi Phil,

Thank you for contacting Syncfusion Support.

We have checked the reported query "No matter what the new tab is created and I can select it manually but it is never activated / focused when added" and we were unable to reproduce the reported behavior in our DockingManager control. But we have prepared the sample to meet your requirement. In this sample, we have set ActiveWindow of DockingManager as Newly added child. Please download the sample for the same from the below link.

Sample: Docking_SelectTab

Note: In our DockingManager control set’s active tab as newly created child by default.

If we have misunderstood your requirement, please provide EssentialStudio version and issue reproducible sample with replication steps. It will help to proceed further on this.

Regards,
Marimuthu S.


PB Phill Barnes August 9, 2017 01:03 PM UTC

Hi

Thank you very much for your response.  I have changed my code a little bit to help me figure out where it is going wrong.  The sample you provided is pretty much exactly how i had it and it works perfectly.  The only difference was the way in which the method was called.  Your sample was on button click.  The way i was calling this method was from a DataGrid_MouseDoubleClick event and I've discovered this is where the issue lies.

If i keep double clicking sometimes it activates the new tab, it all seems to be about timing.  Perhaps the second click is overriding focus or similar I'm really not sure.  I added a button to the grid row to run the exact same method and it works every time.  It just does not like being called (or should i say its temperamental) from the DataGrid DoubleClick event.

Do you have any suggestions on why that could be?  



MS Marimuthu Sivalingam Syncfusion Team August 10, 2017 11:50 AM UTC

Hi Phill,

Thanks for your update.

We have checked your query and we could reproduce the reported behavior. In our DockingManager, we have changed the SelectedItem while MouseDown on TabItem content. In your scenario, you have double clicked on DataGrid control, to add new DocumentTab. It triggered the MouseDown event of TabItem Content after new Document Tab was added. So, Active Document was changed from newly added Tab to last previous SelectedItem. So, this issue occurs from your side. Now, we have prepared the sample to meet your requirement. In this sample, we have handled the MouseDoubleClick Event of DataGrid to cancel the MouseDown event of TabItem content. Please download the sample for the same.

Sample:  modified_Docking_SelectTab

If, we have misunderstood your query please provide more details with your sample codes. It will help to proceed further.

Regards,
Marimuthu S.



PB Phill Barnes August 11, 2017 08:20 AM UTC

Hi,

Thank you! 

It was as simple as that, much appreciated ;)




MS Marimuthu Sivalingam Syncfusion Team August 14, 2017 11:24 AM UTC

Hi Phill,

Thank you for your update.

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

Regards,
Marimuthu S.


Loader.
Up arrow icon