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.
    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>

























  2. Milena
    Admin
    Milena avatar
    204 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.

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