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

RadDataBoundListBox containing RadExpander in DataTemplate

2 Answers 64 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Justin
Top achievements
Rank 1
Justin asked on 01 Jul 2013, 03:08 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 02 Jul 2013, 07:22 AM
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.
0
Justin
Top achievements
Rank 1
answered on 03 Jul 2013, 06:44 AM
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.
Tags
DataBoundListBox
Asked by
Justin
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Justin
Top achievements
Rank 1
Share this question
or