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

To acess controls on click of Hyperlinkbutton in RadPanelBar for Silverlight

1 Answer 68 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Sukhminder
Top achievements
Rank 1
Sukhminder asked on 20 Jul 2011, 09:07 AM
Hi

I am using the following code to bind the data to the RadPanelBar for Silverlight, It works fine.
I have a HyperLinkButton in my PanelBar. my question, On the click of a hyperlinkbutton, how can I access the other two controls i.e. textBlocks (CategoryTitle and Score) of the same row?

 <UserControl.Resources>
        <DataTemplate x:Key="PanelBarItemTemplate">
            <Grid x:Name="grdCategory" ShowGridLines="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60*"></ColumnDefinition>
                    <ColumnDefinition Width="40*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid x:Name="grdSubCategory" Grid.Column="0" Style="{StaticResource CategoryLeftStyle}" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50*"></ColumnDefinition>
                        <ColumnDefinition Width="25*"></ColumnDefinition>
                        <ColumnDefinition Width="25*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding CategoryTitle}" Grid.Row="0" Grid.Column="0"/>
                    <HyperlinkButton Grid.Row="0" Grid.Column="1" Style="{StaticResource DetailLinkStyle}" Content="Details" Click="Home_Click"></HyperlinkButton>
                    <TextBlock Text="{Binding Score}" Grid.Row="0" Grid.Column="2"/>
                </Grid>
                <TextBlock Text="92%" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" FontSize="32" FontWeight="Bold"/>
            </Grid>
        </DataTemplate>

        <telerik:HierarchicalDataTemplate x:Key="PanelBarHeaderTemplate"
                                  ItemsSource="{Binding SubReports}"
                                  ItemTemplate="{StaticResource PanelBarItemTemplate}">
            <TextBlock Text="{Binding CategoryTitle}" />
        </telerik:HierarchicalDataTemplate>

    </UserControl.Resources>
<telerik:RadPanelBar x:Name="radPanelBar"
                                     ItemTemplate="{StaticResource PanelBarHeaderTemplate}"
                                     IsSingleExpandPath="False" ItemClick="radPanelBar_ItemClick">
                    </telerik:RadPanelBar>

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 Jul 2011, 01:37 PM
Hello Sukhminder,

 You can use the telerik`s extension methods ParentOfType<> and ChildrenOfType<> like so:

using Telerik.Windows.Controls;
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
       {
           Grid parentGrid = (sender as HyperlinkButton).ParentOfType<Grid>();
           if (parentGrid != null)
           {
               TextBlock t = parentGrid.ChildrenOfType<TextBlock>()[0];
               if (t != null)
               {
 
               }
           }
       }

Kind regards,
Petar Mladenov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
PanelBar
Asked by
Sukhminder
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or