New to Telerik UI for WPF? Download free 30-day trial

Find a control in RowDetailsTemplate

This article demonstrates how to find a control which is placed in the DataTemplate of the RowDetailsTemplate.

Let assume that you have a control (RadComboBox) in the RowDetailsTemplate which you need to set some properties at runtime:

<telerik:RadGridView.RowDetailsTemplate> 
    <DataTemplate> 
        <StackPanel> 
            <telerik:RadComboBox Name="rcbCountries" /> 
            <!-- some other controls here --> 
        </StackPanel> 
    </DataTemplate> 
</telerik:RadGridView.RowDetailsTemplate> 
The best way to do this is to subscribe to the LoadingRowDetails event and find the control there:

<telerik:RadGridView Name="gridView"  
ItemsSource="{Binding Source={StaticResource itemsList}}" 
LoadingRowDetails="gridView_LoadingRowDetails" 
RowDetailsVisibilityMode="VisibleWhenSelected"> 
In the LoadingRowDetails event handler use the FindName method of the e.DetailsElement:

private void gridView_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e) 
{ 
    RadComboBox countries = e.DetailsElement.FindName("rcbCountries") as RadComboBox; 
    countries.ItemsSource = GetCountries(); 
} 
Private Sub gridView_LoadingRowDetails(sender As Object, e As GridViewRowDetailsEventArgs) 
    Dim countries As RadComboBox = TryCast(e.DetailsElement.FindName("rcbCountries"), RadComboBox) 
    countries.ItemsSource = GetCountries() 
End Sub 

See Also

In this article