Disable C1TabItems

Posted by: uhlmandanl on 12 April 2023, 4:22 am EST

    • Post Options:
    • Link

    Posted 12 April 2023, 4:22 am EST

    We recently update our version of Component1 for UWP. Prior to this version, setting “IsEnabled” to false on a C1TabItem would make the tab header appear disabled (is “grey” vs. “black”). With the upgrade, this does not appear to do the same. The header stays “black” and appears to be selectable, but it is not. I’ve tried the “IsSlectable” property but that does nothing for the appearance. Is there a property on the C1TabItem that will give the disabled tab a “disabled” look? Our version is 10.0.20222.770.

  • Posted 12 April 2023, 7:44 pm EST

    Hi,

    In order to change the color of disabled C1TabItem, you can handle the Loaded event as:

           private void Loaded_TabControl(object sender, RoutedEventArgs e)
            {
                foreach (C1TabItem s in tabControl.Items)
                {
                    if (!s.IsEnabled)
                    {
                        var s1 =FindMyChildByName(s, "C1TabItemPresenter") as C1TabItemPresenter;
                        (s1.Parent as Grid).Background = new SolidColorBrush() { Color = Windows.UI.Color.FromArgb(255, 255, 0, 0) };
                    }
                }
            }
            public static DependencyObject FindMyChildByName(DependencyObject parant, string ControlName)
            {
                int count = VisualTreeHelper.GetChildrenCount(parant);
    
                for (int i = 0; i < count; i++)
                {
                    var MyChild = VisualTreeHelper.GetChild(parant, i);
                    if (MyChild is FrameworkElement && ((FrameworkElement)MyChild).Name == ControlName)
                        return MyChild;
    
                    var FindResult = FindMyChildByName(MyChild, ControlName);
                    if (FindResult != null)
                        return FindResult;
                }
                return null;
            }

    Please refer to the attached sample for the same: C1TabDemo.zip

    Best Regards,

    Nitin

  • Posted 12 April 2023, 11:40 pm EST

    Thanks Nitin! That will work. Have a great day.

    Thanks,

    Dan

Need extra support?

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

Learn More

Forum Channels