How to get dynamic controls from RadExpander

3 posts, 0 answers
  1. Sreedevi
    Sreedevi avatar
    4 posts
    Member since:
    Sep 2011

    Posted 08 Dec 2011 Link to this post

    Hi,

    We are using Radexpander control,while loading expander inernally we are adding some controls(Textboxes,Combobx.........).here i want to get the all controls  which are available in the Radexpander .please guide me to resolve this.it's very very urgent for me.


    Thanks,
    -Sree
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 13 Dec 2011 Link to this post

    Hello Sreedevi,

    You can find the content of the RadExpander through its Content property. It will return the root control used as a content of the control. Then you can traverse through the children of this item and so on until you get all UIElements used in the RadExpander.Content.

    For example:
    private void AddContent(RadExpander expander)
    {
        expander.Header = "MyExpander";
     
        StackPanel panel = new StackPanel();
     
        TextBlock txt = new TextBlock { Text="TextBlock 1"};
        panel.Children.Add(txt);
     
        RadComboBox combo = new RadComboBox();
        combo.Items.Add(new RadComboBoxItem { Content = "Item 1" });
        combo.Items.Add(new RadComboBoxItem { Content = "Item 2" });
        combo.Items.Add(new RadComboBoxItem { Content = "Item 3" });
        panel.Children.Add(combo);
     
        expander.Content = panel;
    }
     
    private void GetContent(RadExpander expander)
    {
        string header = expander.Header.ToString();
     
        StackPanel panel = expander.Content as StackPanel;
        if (panel != null)
        {
            foreach (var item in panel.Children)
            {
                //get the UIElements declared in the RadExpander.Content
            }
        }
                 
    }

    Is this what you were looking for or am I missing something?

    Best wishes,
    Tina Stancheva
    the Telerik team

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

  3. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 16 Dec 2011 Link to this post

    Hello Sreedevi,

    I wanted to follow up on your question, as we received a similar mail, I believe it might be from a collegue of yours. The mail pointed me to teh fact that you're trying to get the Content of the RadExpander in the context of TestStudio.

    This is why I wanted to let you know that in TestStudio you can get the content of the RadExpander control through a ContentPresenter. Basically when you try to access the RadControls for Silverlight using Test Studio, you'll have to follow the structure of the VisualTree as the TestStudio will give you access to those elements. Having this in mind, you can get the RadExpander header element through a RadToggleButton and its Content through a ContentPreseneter. However, the content of the ContentPresenter will depend on the visual tree structure that you build in the definition of the control.

    Also, if you can elaborate on the scenario you need to implement - why you need to access the content of the RadExpander, we will be able to better assist you and we might be able to suggest you different approaches.

    Best wishes,
    Tina Stancheva
    the Telerik team

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

Back to Top