To acess controls on click of Hyperlinkbutton in RadPanelBar for Silverlight

2 posts, 0 answers
  1. Sukhminder
    Sukhminder avatar
    2 posts
    Member since:
    Jul 2011

    Posted 20 Jul 2011 Link to this post

    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>
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Jul 2011 Link to this post

    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!

  3. DevCraft banner
Back to Top