FindName in TabControl

2 posts, 1 answers
  1. Kelley Wong
    Kelley Wong avatar
    21 posts
    Member since:
    May 2010

    Posted 14 May 2012 Link to this post

    I create a tabcontrol which contains two tabitem
    code as follows:
    <Grid x:Name="LayoutRoot">
            <telerik:RadTabItem Header="Test1">
                <Button Content="Click"
                        Click="Tbtn_Click" />
            <telerik:RadTabItem Header="Test2">
                <Button Content="Click"
                        Click="btn_Click" />

    private void btn_Click(object sender, RoutedEventArgs e)
                Object obj = LayoutRoot.FindName("Tbtn");
            private void Tbtn_Click(object sender, RoutedEventArgs e)
                Object obj = LayoutRoot.FindName("btn");

    first , the test1 tabitem is selected , i click the button to get another button in test2 tabitem,it returns well

    then i selected the test2 tabitem , i click the button to get the button in test1 tabitem ,it returns null

    and then i selected the test1 tabitem again , click the button ,it returns null 

    what should i do if i selected the second tabitem, i want to get a control which in the first tabitem ,and suggestions?

    thanks in advance
  2. Answer
    Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 17 May 2012 Link to this post

    Hi Kelley,

    You can set the RadTabControl.IsContentPreserved property to True. You can find more info about that property here.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top