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

Exception when removing element

1 Answer 45 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.
Doug
Top achievements
Rank 1
Doug asked on 26 Jun 2012, 10:17 AM
Hi

I have a problem with the databound listbox, when I have one element in the list and I remove it, and I want to add a new element instead I get the following exception:

  at Telerik.Windows.Controls.RadDataBoundListBox.GetLastItemCacheIndex()
   at Telerik.Windows.Controls.VirtualizationStrategy.RefreshViewportOnItemAdded(IDataSourceItem addedItem)
   at Telerik.Windows.Controls.RadVirtualizingDataControl.UpdateViewportOnItemsChange(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Controls.RadVirtualizingDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Controls.RadDataBoundListBox.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Controls.RadVirtualizingDataControl.OnListSource_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)

I have also created a sample application showing what I am doing:

Xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Telerik:RadDataBoundListBox Grid.Row="1" Name="TestListbox" DataVirtualizationMode="OnDemandAutomatic" CacheMode="BitmapCache" ItemsSource="{Binding TestStringCollection}">
                <Telerik:RadDataBoundListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}" />
                    </DataTemplate>
                </Telerik:RadDataBoundListBox.ItemTemplate>
            </Telerik:RadDataBoundListBox>
        </Grid>


C#:

namespace RadControlsWindowsPhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        public ObservableCollection<string> TestStringCollection { get; private set; }


        // Constructor
        public MainPage()
        {
            InitializeComponent();


            TestStringCollection = new ObservableCollection<string>();
            TestStringCollection.Add("a");


            DataContext = this;
        }


        private void TestButtonClick(object sender, EventArgs e)
        {
            TestStringCollection.Remove("a");
            TestStringCollection.Add("b"); //Exception here
        }
    }
}

If I have 2 items in the listbox this doesn't happen.

I would like you to offer a work around this and to fix it as soon as possible. Thanks in advance.

Best Regards Doug

1 Answer, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 26 Jun 2012, 11:51 AM
Hi Doug,

Thanks for writing and for reporting this issue.

We have been able to reproduce it and to identify the reason for it.

A fix will be available in the upcoming Q2 2012 SP1 which is due to in a week.

Let me know in case you have further questions or need assistance.

Greetings,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DataBoundListBox
Asked by
Doug
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or