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

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

2 Answers 189 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nguyen
Top achievements
Rank 1
Nguyen asked on 03 Aug 2012, 04:51 AM
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!

Nguyen

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 03 Aug 2012, 08:17 AM
Hi,

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
GridViewHeaderCell.ChildrenOfType<TextBox>().

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

Greetings,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Nguyen
Top achievements
Rank 1
answered on 03 Aug 2012, 09:05 AM
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,
Nguyen
Tags
GridView
Asked by
Nguyen
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Nguyen
Top achievements
Rank 1
Share this question
or