How access child controls in the Header & Cell DataTemplate under a RadGridView

3 posts, 0 answers
  1. Nguyen
    Nguyen avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Aug 2012 Link to this post

    Hi Telerik,

    I'm using a RadGridView control in the Silverlight 5. In this grid has some columns contain DataTemplate on both of Header and Rows. I try to access these child controls by using FindByChildType. Anyone knows how to get child controls in the RadGridView please give me a solution. Thanks so much!

  2. Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 03 Aug 2012 Link to this post


    In case you add an "using Telerik.Windows.Controls directive to your cs file ,
    you can use the ChildrenOfType<> extension method.

    for example : RadGridView.ChildrenOfType<GridViewHeaderCell>() or

    Of course you should call these methods at the proper time - when the visuals have been already loaded to the visual tree.

    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Nguyen
    Nguyen avatar
    4 posts
    Member since:
    Aug 2012

    Posted 03 Aug 2012 Link to this post

    First, thank Telerik replied asap. I'm using the line code below for getting a list column:
    List<GridViewBoundColumnBase> columns = (from c in grid.Columns.OfType<GridViewBoundColumnBase>()
                                                         where c.IsVisible == true
                                                         orderby c.DisplayIndex
                                                         select c).ToList();
    It returns to me a list column as we expected. After that, on per specific column, ex: column[i], I would like to find all child controls in it to get out some element such as TextBlock, Image... I used all of case you exposed but not successful. Using Telerik.Windows.Controls, of course, it's imported to the cs file. Even though, when I switch to use List<GridViewColumn>, I haven't seen the correct solution so that resolve the expectation.

    Certainly, all UI elements are loaded complete before I click on a button for working arround. Please help me to find out a good solution for resolving this trouble that I have met. 

    Thank you very much,
Back to Top