This is a migrated thread and some comments may be shown as answers.

RadTabItem object not found until it is selected or gets focus

1 Answer 51 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Kam
Top achievements
Rank 2
Kam asked on 03 Apr 2012, 05:04 PM
Our scenario is as follows:

We have 4 tabitems for a RadTabControl (Tab1, Tab2, Tab3, Tab4) in this order and Tab1 is set as the selected tab when the RadTabControl is loaded for the first time.

The parent user control that wraps this RadTabControl when tries to find the Tab4 (without Tab4 set to focus or a manual user selection), the following code we run by in Framework is unable to locate it.. 

To reiterate the point, if that Tab4 is set as the first tab item or has focus or has a manual user selection - the same piece of code locates the Tab4.

        private static T FindChild<T>(DependencyObject parent) where T : DependencyObject

        {

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)

            {

                DependencyObject child = VisualTreeHelper.GetChild(parent, i);

                if (child != null && child is T)

                    return (T)child;

                else

                {

                    T childOfChild = FindChild<T>(child);

                    if (childOfChild != null)

                        return childOfChild;

                }

            }

            return null;

        }


Let us know if there is a property that we can apply for a specific RadTabItem to ensure the tabitem object is created as soon as the RadTabControl (as a container object) is created/loaded.

Thanks much
Kam Panchal

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 04 Apr 2012, 08:33 AM
Hi,

I've tried to simulate the issue but with no avail. I've prepared a sample project with your code included (copy paste from your post). Could you please give it a try and change it to simulate the issue?

On a side note, I just wanted to encourage you to take advantage of the support ticketing system (http://www.telerik.com/account/support-tickets/new-support-ticket.aspx) in cases when you need a prompt response to urgent issues. This is the best way to reach our support staff and attach a sample project.

All the best,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TabControl
Asked by
Kam
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Share this question
or