How can i disable tab in dockingmanager control

Hello,

I have a docking manager that contains a list and several contentcontrols with State=document acting as tabs.
I want to disable (to stop the possibility to enter) other tabs when i am in tab 1 for example.

Here is my code:

<syncfusion:DockingManager x:Name="dockingManager" IsVS2010DraggingEnabled="False" IsEnableHotTracking="False" DisabledCloseButtonsBehavior="Hide" DocumentCloseButtonType="Hide" IsContextMenuVisible="False" IsContextMenuButtonVisible="False" ShowTabItemContextMenu="False" ShowTabListContextMenu="False" IsTDIDragDropEnabled="False" Loaded="dockingManager_Loaded" MouseDown="dockingManager_MouseDown" EnableMouseHoverBackground="False" IsTabPreviewEnabled="False" UseDocumentContainer="True">
                <syncfusion:DockingManager.Icon>
                    <ImageBrush ImageSource="Images\icon.PNG"/>
                </syncfusion:DockingManager.Icon>

                <syncfusion:DockingManager.DocumentTabControlStyle>
                    <Style TargetType="{x:Type syncfusion:DocumentTabControl}">
                        <Setter Property="TabItemSelectedBackground" Value="Green" />
                    </Style>
                </syncfusion:DockingManager.DocumentTabControlStyle>

                <!-- Sample Window -->
                <ListBox Name="lst"  BorderThickness="0" syncfusion:DockingManager.CanClose="False" syncfusion:DockingManager.CanDockonFloat="False"
                         syncfusion:DockingManager.CanDrag="False" SelectionChanged="lstCars_SelectionChanged"
                         syncfusion:DockingManager.CanResizeInDockedState="False"
                         syncfusion:DockingManager.CanResizeWidthInDockedState="False"
                             syncfusion:DockingManager.SideInDockedMode="Left" 
                             syncfusion:DockingManager.State="Dock" 
                             syncfusion:DockingManager.DesiredWidthInDockedMode="220"  
                             syncfusion:DocumentContainer.MDIBounds="30,30,300,300"  
                             syncfusion:DockingManager.DesiredHeightInFloatingMode="200"
                             syncfusion:DockingManager.Header="Cars"
                         
                         Style="{DynamicResource ResourceKey=styleListBox}"
                         >
                </ListBox>

<ContentControl  syncfusion:DockingManager.State="Document" syncfusion:DockingManager.Header="TAB_1"  Name="tab1" syncfusion:DockingManager.DocumentTabOrderIndex="1" >

<Grid x:Name="grdBelt" Background="Transparent">
<Button Content="Disable other tabs" Name="btnDisable" Click="btnDisable_Click"/>
<Button Content="Enable other tabs" Name="btnEnable"/>
</Grid>
</ContentControl>

<ContentControl  syncfusion:DockingManager.State="Document" syncfusion:DockingManager.Header="TAB_2"  Name="tab2" syncfusion:DockingManager.DocumentTabOrderIndex="2" >

<ContentControl  syncfusion:DockingManager.State="Document" syncfusion:DockingManager.Header="TAB_3"  Name="tab3" syncfusion:DockingManager.DocumentTabOrderIndex="3" >

</syncfusion:DockingManager>


I tried on btnDisable click event:

private void btnDisable_Click(object sender, RoutedEventArgs e)
        {
            ////this is not ok because it disables everyting, including current tab (tab 1)
            //dockingManager.IsEnabled = false;
              
            //// and here i want to disable (stop the user to enter, to click the headers of the other tabs (tab2 and tab3)
               tab2.IsEnabled = false;  
               tab3.IsEnabled = false;
            //// but the user can still click the headers of tab2 and tab3 and enter 
}


Thank you,
Bogdan


1 Reply

DR Durga Rajan Syncfusion Team January 8, 2018 09:43 AM UTC

Hi Bogdan, 

Thanks for contacting Syncfusion support. 

The requirement can be achieved in two ways. We suggest you to disable DocumentTabItems instead of disabling tab item's content. Another way to disable selection of tab is, restrict the selection of new tab in ActiveWindowChanging event. We have prepared sample which tries to meet your requirement. In this sample we have retrieved the document tab items from the DockingManager and disable the inactive tab items. Also, we have restricted the selection of the other tabs in ActiveWindowChanging event. Please find the code snippets from below the table, 

Disabling Tabitems: 

        private void DisableOtherTabs(string nameForFind, bool value) 
        { 
            foreach (TabItemExt element in documenttab.Items) 
            { 
                if (nameForFind != element.Header.ToString()) 
                { 
                    element.IsEnabled = value; 
                     
                } 
            }          
        } 

Restricting new tab selection in ActiveWindowChanging event: 
 
    if (oldelement != null && oldelement.Name == dockingManager.ActiveWindow.Name && DockingManager.GetState(newelement) == DockState.Document) 
                { 
                    e.Cancel = true; 
                } 
 
Please download the sample for the same from below location and let me know your suggestions, 

 
 
Please get back to us if the sample doesn’t meet your requirement.  

Regards, 
Durga S. 


Loader.
Up arrow icon