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

Get Value of Selected Item

1 Answer 23 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Chazz
Top achievements
Rank 1
Chazz asked on 11 Jun 2014, 05:38 PM
I am having an issue getting the value of the selected subitems in a panel bar.
There is a main heading "by State" and the subitems are a list of states, TX, CA, NC, NY etc..

I have this code from another example:

1.
1.private void panelBar1_Selected(object sender, Telerik.Windows.RadRoutedEventArgs e)RadPanelBarItem container = e.Source as RadPanelBarItem;
var textBlocksCollection = container.ChildrenOfType<TextBlock>();
var testmessage = container.ToString();
MessageBox.Show(testmessage);
// RadPanelBarItem pbBarItem = e.Source as RadPanelBarItem;
//TextBlock Name = pbBarItem.ChildrenOfType<TextBlock>();
//MessageBox.Show(Name.Text);
MessageBox.Show(textBlocksCollection.Count().ToString() + " text blocks found");<br>        }




It will spit out "Silverlight.Application.DataItem", but i see no way to get to the actual value.(need to know which stat they selected)
Even the code that is commented out(which one user said fixed this problem) does not work. 

Can some shed some light on how to get the actual value of the selected item?



the Xaml is:


<UserControl x:Class="SilverlightApplication2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<UserControl.Resources>
<telerik:HierarchicalDataTemplate x:Key="DataItemTemplate" ItemsSource="{Binding Items}">
<StackPanel>
<TextBlock Text="{Binding Text}" />
<TextBlock Text="{Binding Text}" />
</StackPanel>
</telerik:HierarchicalDataTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<telerik:RadPanelBar x:Name="panelBar1" ItemTemplate="{StaticResource DataItemTemplate}"
Selected="panelBar1_Selected" />
</Grid>
</UserControl>

























1 Answer, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 16 Jun 2014, 12:41 PM
Hello Chazz,

I'd suggest you another approach. You can use the business object in the selected PanelBarItem and use its properties instead of invoking the ChildrenOfType. For your convenience I implemented this approach in the attached project (I tried to follow your code).

Please take a look at it and let us know if it works for you or in case any further assistance is needed.

Regards,
Milena
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PanelBar
Asked by
Chazz
Top achievements
Rank 1
Answers by
Milena
Telerik team
Share this question
or