This question is locked. New answers and comments are not allowed.
Hi,
I have a problem using the the RadDataBoundListBox. Its ItemSource is set to an ObservableCollection but the ListBox is not updated automatically when the Collection is changed or completely replaced:
Whenever the UpdateList() Methode is called nothing happens - new items are not shown, deleted items are still visible, etc. Only when using the Toogle function to switch between Grid and List Layout the ListBox is Updated and all Items are shown correctly.
Setting RadListBox.ItemSource to a complete new instance of
UPDATE:
I have to correct myselfe. The Update works properly when the List Layout is used but not in Grid mode.
I have a problem using the the RadDataBoundListBox. Its ItemSource is set to an ObservableCollection but the ListBox is not updated automatically when the Collection is changed or completely replaced:
<
DataTemplate
x:Key
=
"GridItemTemplate"
>
<
Border
Background
=
"#365F70"
Width
=
"128"
Height
=
"128"
Margin
=
"24,0,0,24"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"80"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
ContentControl
Template
=
"{Binding Template}"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Center"
Margin
=
"-15,0,0,0"
>
<
ContentControl.RenderTransform
>
<
CompositeTransform
ScaleX
=
"1.5"
ScaleY
=
"1.5"
/>
</
ContentControl.RenderTransform
>
</
ContentControl
>
<
TextBlock
Text
=
"{Binding Name}"
FontSize
=
"20"
Grid.Row
=
"1"
VerticalAlignment
=
"Center"
HorizontalAlignment
=
"Center"
/>
</
Grid
>
</
Border
>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"ListItemTemplate"
>
<
Border
Background
=
"#365F70"
Height
=
"72"
Margin
=
"24,0,24,12"
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
ContentControl
Margin
=
"10,-15,35,0"
Template
=
"{Binding Template}"
VerticalAlignment
=
"Center"
>
<
ContentControl.RenderTransform
>
<
CompositeTransform
ScaleX
=
"1.5"
ScaleY
=
"1.5"
/>
</
ContentControl.RenderTransform
>
</
ContentControl
>
<
TextBlock
Text
=
"{Binding Name}"
FontSize
=
"20"
VerticalAlignment
=
"Center"
/>
</
StackPanel
>
</
Border
>
</
DataTemplate
>
<
telerikPrimitives:RadDataBoundListBox
x:Name
=
"RadListBox"
ItemTemplate
=
"{StaticResource GridItemTemplate}"
ItemTap
=
"RadListBox_OnItemTap"
ItemReorderStateChanged
=
"RadListBox_ItemReorderStateChanged"
/>
ObservableCollection<Data> dataList;
private
void
UpdateDataList() {
if
(dataList ==
null
) {
dataList=
new
ObservableCollection<Data>();
RadListBox.ItemsSource = dataList;
}
else
{
dataList.Clear();
}
for
(
int
i = 0; i < DataSource.Count; i++) {
Data data = DataSource[i];
dataList.Add(data);
}
RadListBox.UpdateLayout();
}
private
void
ToggleClick(
object
sender, EventArgs e) {
if
(listShown) {
RadListBox.ItemTemplate = (DataTemplate)Resources[
"GridItemTemplate"
];
RadListBox.VirtualizationStrategyDefinition =
new
WrapVirtualizationStrategyDefinition { Orientation = System.Windows.Controls.Orientation.Horizontal };
RadListBox.IsItemReorderEnabled =
false
;
}
else
{
RadListBox.ItemTemplate = (DataTemplate)Resources[
"ListItemTemplate"
];
RadListBox.VirtualizationStrategyDefinition =
new
StackVirtualizationStrategyDefinition { Orientation = System.Windows.Controls.Orientation.Vertical };
RadListBox.IsItemReorderEnabled =
true
;
}
}
Whenever the UpdateList() Methode is called nothing happens - new items are not shown, deleted items are still visible, etc. Only when using the Toogle function to switch between Grid and List Layout the ListBox is Updated and all Items are shown correctly.
Setting RadListBox.ItemSource to a complete new instance of
ObservableCollection instead of Cleaning and re-filling the existing one does not work either.
UPDATE:
I have to correct myselfe. The Update works properly when the List Layout is used but not in Grid mode.