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

Close button doesn't work in DocumentContainer

Hi, 
I am starting to use DocumentContainer, but I have some difficulty getting it to work:

<!-- In XAML Code -->
<syncfusion:DocumentContainer 
            x:Name="_MainDockManager" 
            Mode="TDI"
            Grid.Row="1">
</syncfusion:DocumentContainer>


//Code behind
public FrameworkElement ExistDocumentInDocumentContainer(string name_) {      foreach (FrameworkElement element in _MainDockManager.Items) { if (name_.ToLower() == element.Name) { return element; }      }      return null; }   


private void ButtonTest_Click(object sender, RoutedEventArgs e) {
     string title = "HeaderTitle";
     var doc = ExistDocumentInDocumentContainer(title)
     if (doc == null)
     {
           doc = new myUserControl();
           DocumentContainer.SetHeader(doc, title);      doc.Name = title.ToLower();
_MainDockManager.Items.Add(doc);       
     }
     else
     {
          _MainDockManager.ActiveDocument = doc_;
     }
}
  
What I want to achieve is to check if the document already exists in the DocumentContainer.
If exists, then activate it else add a new obejct to the DocumentContainer.
Everything seemed to work, but whenever I close the document in the x button in the right top corner of the DocumentContainer, it stays in the DocumentContainer items list and i can´t active it or show it.

What am I doing wrong, is it the right approach?
Thanks


2 Replies

UN Unknown Syncfusion Team December 3, 2019 12:51 PM UTC

Hi José António, 
 
Thanks for contacting Syncfusion support. 
 
We are analyzing your query regarding the “When close the document in DocumentContainer the items list is not updated” and we will update your regarding this query on 5th December 2019. 
 
Regards, 
Niranjan Kumar. 



UN Unknown Syncfusion Team December 4, 2019 11:27 AM UTC

Hi José António, 
 
We have analyzed your query regarding “When close the document in DocumentContainer the items list is not updated”.  By default when tab item is closed tab item is hidden. Please use ‘RestoreDocument’ method, to restore and activate the closed document, as shown in following code example. 
 
C#: 
private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            string title = "HeaderTitle"; 
            var doc = ExistDocumentInDocumentContainer(title); 
             if (doc == null) 
            { 
                doc = new myUserControl(); 
                DocumentContainer.SetHeader(doc, title); 
                doc.Name = title.ToLower(); 
                _MainDockManager.Items.Add(doc); 
 
            } 
            else 
            { 
                _MainDockManager.RestoreDocument(doc as UIElement); 
            } 
        } 
 
 
Regards, 
Niranjan Kumar 


Loader.
Live Chat Icon For mobile
Up arrow icon