RadDataBoundListBox containing RadExpander in DataTemplate

3 posts, 1 answers
  1. Justin
    Justin avatar
    7 posts
    Member since:
    Feb 2013

    Posted 01 Jul 2013 Link to this post

    Hello. I am trying to build a DataBoundListBox of RadExpanders (i.e. a list box where you can click each item and they will expand).

    The code below works until I change ItemsSource of the ListBox to something else and back. Then I get an error:

    Element is already the child of another element

    I have even tried putting the whole Expander into it's own UserControl inside my <Person> object and return a new instance every time but still get this error and I don't like that solution since it breaks MVVM.

    Can someone please point me to the correct way of having a DataBound ListBox containing Expanders.

    Thanks!
    Justin

    <telerikPrimitives:RadDataBoundListBox
                    Grid.Row="0"
                    x:Name="ListBoxMain" ItemsSource="{Binding People, Mode=TwoWay}" Height="700" Margin="3,0,3,3"
                    IsItemReorderEnabled="True"
                    IsCheckModeEnabled="False"
                    IsCheckModeActive="False"
                    IsCheckModeActiveChanged="ListBox_Main_OnIsCheckModeActiveChanged"
                    IsPullToRefreshEnabled="True"
                    RefreshRequested="ListBox_Main_OnRefreshRequested"
                    UseOptimizedManipulationRouting="False">
                        <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition Height="3"></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <telerikPrimitives:RadExpanderControl
                            Grid.Row="0"
                            Content="{Binding}"
                            AnimatedIndicatorContentTemplate="{x:Null}"
                            Background="#FFEAEAEA">
      
                                        <telerikPrimitives:RadExpanderControl.ContentTemplate>
                                            <DataTemplate>
                                                <Grid Margin="0,30" VerticalAlignment="Center">
         
                                                    <TextBlock Grid.Column="4" Text="{Binding Name}"/>
      
                                                </Grid>
                                            </DataTemplate>
                                        </telerikPrimitives:RadExpanderControl.ContentTemplate>
      
                                        <telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
                                            <DataTemplate>
                                                <userControls:HighDetailExpandedContent></userControls:HighDetailExpandedContent>
                                            </DataTemplate>
                                        </telerikPrimitives:RadExpanderControl.ExpandableContentTemplate>
      
                                    </telerikPrimitives:RadExpanderControl>
      
                                </Grid>
                            </DataTemplate>
                        </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
      
                    </telerikPrimitives:RadDataBoundListBox>
                </Grid>
  2. Answer
    Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 02 Jul 2013 Link to this post

    Hi Justin,

    Thanks for writing.

    We would like to investigate the case and therefore sending us a sample project that reproduces the issue will be extremely helpful. Is it possible for you to isolate the case in a sample project or simply send us the source of your app so that we can attach our source code and see what exactly happens?

    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. Justin
    Justin avatar
    7 posts
    Member since:
    Feb 2013

    Posted 03 Jul 2013 Link to this post

    Hi thanks! But I figured it out. Now my datamodel holds an instance to the whole listbox instead of just the expander in the data template.
Back to Top