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

Find StackPanel inside HierarchyChildTemplate

1 Answer 26 Views
GridView
This is a migrated thread and some comments may be shown as answers.
raghul
Top achievements
Rank 1
raghul asked on 22 Nov 2011, 04:56 PM
Hi,

How to find the stackPanel inside HierarchyChildTemplate. Please find the attached coding, when I try to find the value it returns null value, where am I going wrong??

<telerik:RadGridView.HierarchyChildTemplate>
                   <DataTemplate>
                       <StackPanel Orientation="Vertical" x:Name="lstboxStackPanel">
                           <ListBox x:Name="lstBox" Width="800" Height="150"
                            VerticalAlignment="Top" ItemsSource="{Binding ReopenNotes}">
                               <ListBox.ItemTemplate>
                                   <DataTemplate>
                                       <!--<StackPanel Orientation="Horizontal" x:Name="lstboxStackPanel">-->
                                           <Border BorderBrush="Gray" BorderThickness="0 0 0 1" Width="Auto">
                                               <telerik:RadExpander x:Name="radExpander" IsExpanded="True" VerticalContentAlignment="Top" Width="900">
                                                   <telerik:RadExpander.Header>
                                                       <StackPanel x:Name="TestRadExpanderHeader" Orientation="Horizontal">
                                                           <HyperlinkButton Name="hlkUserName" Content="{Binding Author}"></HyperlinkButton>
                                                           <TextBlock Name="txtCmtInfo" Text="{Binding Date}"></TextBlock>
                                                       </StackPanel>
                                                   </telerik:RadExpander.Header>
                                                   <telerik:RadExpander.Content>
                                               <StackPanel x:Name="SplInsideExpander" Orientation="Horizontal" Width="900">
                                                   <TextBlock Name="txtCmtDetails" Text="{Binding Note}" Width="890" TextWrapping="Wrap"></TextBlock>
                                               </StackPanel>
                                                   </telerik:RadExpander.Content>
                                               </telerik:RadExpander>
                                           </Border>
                                       <!--</StackPanel>-->
                                   </DataTemplate>
                               </ListBox.ItemTemplate>
                           </ListBox>
                           <TextBox x:Name="txtCommentsAdd" Width="800" Height="75"></TextBox>
                           <StackPanel x:Name="TestActionFooter" Orientation="Horizontal">
                               <Button x:Name="btnAdd" Content="Add" Width="Auto"></Button>
                               <Button x:Name="btnClear" Content="Clear" Width="Auto"></Button>
                           </StackPanel>
                       </StackPanel>
                   </DataTemplate>
               </telerik:RadGridView.HierarchyChildTemplate>

In the code behind I have the  coding as
StackPanel objTile1 = e.Row.Cells[0].ChildrenOfType<StackPanel>().Where(x => x.Name == "lstboxStackPanel").FirstOrDefault();

I used the above code in RowExpandedChanging event and also in RowLoaded event every where it returns null value. Please let me know how to find the stackpanel.

Regards,

Raghul

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 22 Nov 2011, 05:01 PM
Hi Raghul,

Both events are fired too early , the child template visual tree is not yet rendered and this is why you get null .

As an alternative you may subscribe to the Loaded event of the stack panel in xaml and perform your custom logic inside the event handler.

Kind regards,
Pavel Pavlov
the Telerik team

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

Tags
GridView
Asked by
raghul
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or