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

Exception when add and remove item from radBook by programming

2 Answers 76 Views
Book
This is a migrated thread and some comments may be shown as answers.
King Chan
Top achievements
Rank 1
King Chan asked on 09 Jul 2010, 09:48 PM
Hello,

I was trying to add user control or radBookItem by programming, using methods radBook.Items.Add method and radBook.Items.remove/removeAt/removeAll.

I created the radBook in xaml, then add the item in C#.
When it add the item(s), the radBook works fine.
The number of items in the radBook returned right number too.
But when I try to remove it (removeAll/removeAt(0)/remove) it will gaves me exception saying that the argument is out of range.

If I add the item though xaml, it has no problem with removing it.
But the point is that I need to create the pages dynamically in C#.
Is there something I did wrong?

Debug Log:

1

True

'sllauncher.exe' (Silverlight): Loaded 'c:\Program Files (x86)\Microsoft Silverlight\4.0.50524.0\en-US\mscorlib.debug.resources.dll'

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.dll


Exception:
Specified argument was out of the range of valid values.
Parameter name: index

RadBookItem randomitem = new RadBookItem();
            randomitem.Width = 500;
            randomitem.Height = 500;
            radBook1.Items.Add(randomitem);
  
            Debug.WriteLine(radBook1.Items.Count());
            Debug.WriteLine(radBook1.HasItems);
  
            radBook1.Items.RemoveAll();
            Debug.WriteLine(radBook1.Items.Count());
            Debug.WriteLine(radBook1.HasItems);

2 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 14 Jul 2010, 02:40 PM
Hi King,

This issue is fixed and the fix will be available with our official release which is in few days. I'm attaching a sample project demonstrating your scenario. Have a look at it and let me know if you manage to reproduce the issue again.

Greetings,
Kiril Stanoev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
King Chan
Top achievements
Rank 1
answered on 15 Jul 2010, 06:59 PM
Yes, it worked prefectly, thanaks.
Tags
Book
Asked by
King Chan
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
King Chan
Top achievements
Rank 1
Share this question
or