NextButton in DockTabItem

Posted by: vinothkumar.r2210 on 10 May 2020, 4:28 pm EST

    • Post Options:
    • Link

    Posted 10 May 2020, 4:28 pm EST

    Hi,

    While moving DockTabItem, button named NextButton getting displayed at the bottom of the DockTabItem. Please suggest how to hide that button.

    Thanks and Regards,

    Vinoth Kumar Ravi

  • Posted 11 May 2020, 9:18 pm EST

    Hi Vinoth,

    There does not seem to be a direct property to hide the NextButton. So, you may either use VisualTreeHelper and set the Visiblity to Collapsed, as shown in below code. Or you can use and modify the default Template for C1DockTabControl and set the Visibility property of NextButton, there. You can find the default template installed at: C:\Program Files (x86)\ComponentOne\WPF Edition\C1WPFDocking.4.5.2\XAML location. ```

    private void Button_Click(object sender, RoutedEventArgs e)

    {

    for (int i = 0; i < _dock.Items.Count; i++)

    {

    var item = _dock.Items[i];

    if (item.GetType() == typeof(C1.WPF.Docking.C1DockTabControl))

    {

    var tab = item as C1.WPF.Docking.C1DockTabControl;

    var nxtBtn = FindChild<System.Windows.Controls.Primitives.RepeatButton>(tab, “NextButton”);

    if (nxtBtn != null)

    {

    nxtBtn.Visibility = Visibility.Collapsed;

    }

    }

    else

    {

    var grp = item as C1.WPF.Docking.C1DockGroup;

    foreach (C1.WPF.Docking.C1DockTabControl tabChild in grp.Items)

    {

    var nxtBtn = FindChild<System.Windows.Controls.Primitives.RepeatButton>(tabChild, “NextButton”);

    if (nxtBtn != null)

    {

    nxtBtn.Visibility = Visibility.Collapsed;

    }

    }

    }

    }

    }

    public static T FindChild(DependencyObject parent, string childName)

    where T : DependencyObject

    {

    // Confirm parent and childName are valid.

    if (parent == null) return null;

            T foundChild = null;
    
            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
            for (int i = 0; i < childrenCount; i++)
            {
                var child = VisualTreeHelper.GetChild(parent, i);
                // If the child is not of the request child type child
                T childType = child as T;
                if (childType == null)
                {
                    // recursively drill down the tree
                    foundChild = FindChild<T>(child, childName);
    
                    // If the child is found, break so we do not overwrite the found child. 
                    if (foundChild != null) break;
                }
                else if (!string.IsNullOrEmpty(childName))
                {
                    var frameworkElement = child as FrameworkElement;
                    // If the child's name is set for search
                    if (frameworkElement != null && frameworkElement.Name == childName)
                    {
                        // if the child's name is of the request name
                        foundChild = (T)child;
                        break;
                    }
                }
                else
                {
                    // child element found.
                    foundChild = (T)child;
                    break;
                }
            }
    
            return foundChild;
        }
    
    Ruchir
  • Posted 13 May 2020, 1:03 am EST

    Hi Ruchir,

    Thanks for the reply. I have set visibility collapsed to LineOuter panel in DockTabControl ControlTemplate. Items which are presented in that completely not displayed. I have used above mentioned code snippet too for understanding.

    Thanks for the assistance.

    Thanks and Regards,

    Vinoth Kumar Ravi

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels