There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Accordion Throws Exceptions When Changing ItemsSource
When the accordion is set with a SelectionMode of "One" and the ItemsSource is changed there are two scenarios when a runtime exception is generated.
The first occurs when both the old and new values for the ItemsSource have at least one element in them. In this scenario UnselectItem will generate an RTE when calling ItemContainerGenerator.ContainerFromIndex(index).
The second occurs when the old value of ItemsSource has many elements and the new value has none. In this scenario UnselectItem will throw an RTE when attempting to access Items.
In the attached zip I have provided a small testing project which I used to reproduce these errors. I added the toolkit projects for local debugging. The first scenario can be reproduced using item source 1 then item source 2. The second scenario can be reproduced using item source 2 and then item source 3. The version of Accordion.cs alongside the project is one I have modified to no longer produce these errors. The modifications may or may not be entirely appropriate, but I think they will help illustrate some of the issues.