Hi,
When I added Telerik to my application, I used .Net framework 4.5 and platform target x86. I used a RadCarousel and it worked perfect. Later I had to switch to .Net 4.0 framework and change the Telerik version to v.2014.3.1021.40. But now I have a problem. I reduced the code to a minimum for a test purposes:
<Window x:Class="myBRH.AddPhotosWnd" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="AddPhotosWnd" Height="300" Width="1024"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="10*"/> <ColumnDefinition Width="135*"/> <ColumnDefinition Width="855*"/> <ColumnDefinition Width="16*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="2*"/> <RowDefinition Height="10*"/> <RowDefinition Height="3*"/> <RowDefinition Height="36*"/> <RowDefinition Height="3*"/> </Grid.RowDefinitions> <Button Grid.Column="1" Grid.Row="1" Click="Button_Click"/> <telerik:RadCarousel x:Name="rc" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" HorizontalScrollBarVisibility="Hidden"/> </Grid></Window>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace myBRH{ /// <summary> /// Interaction logic for AddPhotosWnd.xaml /// </summary> public partial class AddPhotosWnd : Window { public AddPhotosWnd() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { string str = "sdfsd"; rc.Items.Add(str); rc.BringDataItemIntoView(rc.Items[0]); } }}The problem:
When second item is added to the RadCarousel.Items, System.InvalidOperationException is thrown with the message: "Collection was modified; enumeration operation may not execute."
Exception is not thrown if I comment out the rc.BringDataItemIntoView(rc.Items[0]); method call.