Get Value of Selected Item

2 posts, 0 answers
  1. Chazz
    Chazz avatar
    2 posts
    Member since:
    May 2014

    Posted 11 Jun 2014 Link to this post

    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.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();
    // RadPanelBarItem pbBarItem = e.Source as RadPanelBarItem;
    //TextBlock Name = pbBarItem.ChildrenOfType<TextBlock>();
    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"
    <telerik:HierarchicalDataTemplate x:Key="DataItemTemplate" ItemsSource="{Binding Items}">
    <TextBlock Text="{Binding Text}" />
    <TextBlock Text="{Binding Text}" />
    <Grid x:Name="LayoutRoot" Background="White">
    <telerik:RadPanelBar x:Name="panelBar1" ItemTemplate="{StaticResource DataItemTemplate}"
    Selected="panelBar1_Selected" />

  2. Milena
    Milena avatar
    226 posts

    Posted 16 Jun 2014 Link to this post

    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.

    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.
Back to Top