Problem with selected event when using databinding panelbar

4 posts, 1 answers
  1. bò avatar
    4 posts
    Member since:
    Oct 2010

    Posted 28 Oct 2010 Link to this post

    Dear all,

    I using a databinding panelbar, but i don't know how to get Header of selected item on selected event.
    XAML file:
    <telerik:HierarchicalDataTemplate x:Key="RadpaneItem" ItemsSource="{Binding Items}">
        <TextBlock Text="{Binding Text}"></TextBlock>
    </telerik:HierarchicalDataTemplate>
    <telerik:RadPanelBar ItemTemplate="{StaticResource RadpaneItem}" />
    CS file
    void radPanelBar_Selected(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                RadPanelBarItem pbBarItem = e.Source as RadPanelBarItem;
                TextBlock Header    = pbBarItem.Header as TextBlock;
            }

    Header return null value and i can't get the name of selected item
    Can't you help me

    P/s: sorry because of my bad english
  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 28 Oct 2010 Link to this post

    Hello bò,

    Please have a look at the attached project as it demonstrates one possible solution to this scenario. However, my recommendation is not to look in the visual structure of the HierarchicalDataTemplate unless it is really necessary. The reason is that traversing the visual tree is an expensive operation and can lead to performance penalties.

    Regards,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. bò avatar
    4 posts
    Member since:
    Oct 2010

    Posted 28 Oct 2010 Link to this post

    Dear Kiril Stanoev,

    Thank for your help. But i want to determined the selected RadPanelBarItem (name, header,.....ect). So i can use it open different xaml page when i select those RadPanelBarItems. Can u give me solution for this scenario.

    Thanks again.
  5. bò avatar
    4 posts
    Member since:
    Oct 2010

    Posted 28 Oct 2010 Link to this post

    I had solved my problem

    void radPanelBar_Selected(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                RadPanelBarItem pbBarItem = e.Source as RadPanelBarItem;
                TextBlock Name= pbBarItem.ChildrenOfType<TextBlock >()[0];
                MessageBox.Show(Name.Text);
            }

    Thanks very much!
Back to Top