This question is locked. New answers and comments are not allowed.
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
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
>