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

Problem with selected event when using databinding panelbar

3 Answers 56 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
asked on 28 Oct 2010, 10:48 AM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 28 Oct 2010, 03:27 PM
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
0
Top achievements
Rank 1
answered on 29 Oct 2010, 04:03 AM
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.
0
Top achievements
Rank 1
answered on 29 Oct 2010, 04:45 AM
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!
Tags
PanelBar
Asked by
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Top achievements
Rank 1
Share this question
or