No events from ListBox in ExpandableContent

4 posts, 0 answers
  1. Shantimohan
    Shantimohan avatar
    42 posts
    Member since:
    Jul 2012

    Posted 01 Jul 2013 Link to this post

    I created a new page using Telerik's template "Expanding List 05". I wanted to get the SelectedItem from the RadDataboundListBox in the ExpandableContentTemplate. But the Tap or SelectionChanged events are not firing from this list box. Only the out list box is firing the events.

    What am I doing wrong? Or how do I get them fired from the inner list box?
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 01 Jul 2013 Link to this post

    Hello Shantimohan,

    Could you please prepare a sample project which reproduces the issue and send it to us for further investigation?

    You will have to open a new support ticket in order to be able to attach files.

    Thanks for your time!

    Regards,
    Deyan
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
  3. DevCraft banner
  4. Qua
    Qua avatar
    1 posts
    Member since:
    Nov 2013

    Posted 24 Dec 2013 Link to this post

    hi telerik.
    i try :
    <telerikPrimitives:RadDataBoundListBox x:Name="tenserver" Margin="12,3,12,0" SelectionChanged="tenserver_SelectionChanged">
        <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
            <DataTemplate>
                <telerikPrimitives:RadExpanderControl ExpandableContent="{Binding}" Content="{Binding}" BorderThickness="0, 3, 0, 0" BorderBrush="{StaticResource PhoneSubtleBrush}" Template="{StaticResource CustomAnimatedIndicatorExpanderTemplate}">
                    <telerikPrimitives:RadExpanderControl.AnimatedIndicatorContentTemplate>
                        <DataTemplate>
                            <Image Margin="0,0,0,6" Source="Images/ExpanderArrow.png"/>
                        </DataTemplate>
                    </telerikPrimitives:RadExpanderControl.AnimatedIndicatorContentTemplate>
                    <telerikPrimitives:RadExpanderControl.ContentTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Margin="1,12,1,20" Text="{Binding Path=server, Converter={StaticResource StringToUpperConverter}}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" FontFamily="Segoe WP" FontWeight="Bold" Foreground="{StaticResource PhoneForegroundBrush}"/>
                            </Grid>
                        </DataTemplate>
                    </telerikPrimitives:RadExpanderControl.ContentTemplate>
                    <telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
                        <DataTemplate>
                            <Grid Margin="0,0,0,24">
                                <telerikPrimitives:RadDataBoundListBox x:Name="tapphim"  ItemsSource="{Binding eps}" IsHitTestVisible="False" SelectionChanged="tapphim_SelectionChanged" Tap="tapphim_Tap">
                                    <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Grid Margin="37,6">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="Auto"/>
                                                    <ColumnDefinition/>
                                                </Grid.ColumnDefinitions>
                                                <Image Width="87" Height="87" Source="/Images/FrameThumbnail.png"/>
                                                <StackPanel Grid.Column="1">
                                                    <TextBlock Margin="12,20,12,0" Grid.Column="1" Text="{Binding ep_name}" TextWrapping="Wrap" FontFamily="Segoe WP SemiLight" FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="{StaticResource PhoneForegroundBrush}"/>
                                                    <!--<TextBlock Margin="12,0" Grid.Column="1" Text="{Binding ep_video_url}" TextWrapping="Wrap" Foreground="{StaticResource PhoneForegroundBrush}"/>-->
                                                </StackPanel>
                                            </Grid>
                                        </DataTemplate>
                                    </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                                </telerikPrimitives:RadDataBoundListBox>
                            </Grid>
                        </DataTemplate>
                    </telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
                </telerikPrimitives:RadExpanderControl>
            </DataTemplate>
        </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
    </telerikPrimitives:RadDataBoundListBox>
    I can not get the data in RadDataBoundListBox x:Name="tapphim" with event SelectionChanged="tapphim_SelectionChanged" or Tap="tapphim_Tap"

  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 30 Dec 2013 Link to this post

    Hi Qua,

    I tested the template and here's the observed (and expected) behavior:

    The page contains 1 RadDataBoundListBox. It contains 4 items. Each of them is a RadExpanderControl with 3 items. When you tap on each of the 12 items total, the RadDataBoundListBox's Tap event is fired. The SelectionChanged event on the other hand is fired only when the selection in RadDataBoundListBox is changed. Knowing that it contains only 4 items (the expander controls), you need to tap on an expander control that will change the current selection in order to have the event fired. If you need to get the item that is tapped you can use the following approach:
    private void RadDataBoundListBox_Tap(object sender, System.Windows.Input.GestureEventArgs e)
    {
        RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor<RadDataBoundListBoxItem>(e.OriginalSource as DependencyObject);
        DataItemViewModel model = item.Content as DataItemViewModel;
    }

    Alternatively, you can use the RadDataBoundListBox's ItemTap event:
    private void RadDataBoundListBox_ItemTap(object sender, ListBoxItemTapEventArgs e)
    {
        DataItemViewModel model = e.Item.Content as DataItemViewModel;
    }

    I hope this information helps.

    Regards,
    Todor
    Telerik
    Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Back to Top
DevCraft banner