bug: UI Theme Changing is Broken if there is a <Carousel />
See original GitHub issueDescribe the bug
After bumping Avalonia version from 0.9.12 to 0.10.0 theme changing via window.Styles[0] = new StyleInclude is no longer working properly. E.g. every second time I change the theme, the theme is applied correctly but then someone is resetting the styles, see the GIF below:

Update (28.02.2021)
The errors seem to be coming from the <Carousel /> control.
Theme changing works perfectly if I remove the <Carousel />, see https://github.com/AvaloniaUI/Avalonia/issues/5530#issuecomment-787417903
Also a <Carousel /> occasionally throws a KeyNotFoundException, see https://github.com/AvaloniaUI/Avalonia/issues/5530#issuecomment-787050397
To Reproduce
Here is the repro. Steps to reproduce the behavior:
git clone https://github.com/worldbeater/Camelotia.gitgit checkout updates(a branch with Avalonia 0.10.0)- Launch
src/Camelotia.Avalonia.slnor docd src/Camelotia.Presentation.Avalonia && dotnet run - Press
Switch Thememultiple times
On master (Avalonia 0.9.12) theme changing works fine, on updates (Avalonia 0.10.0) theme changing is broken.
Expected behavior
Theme changing at runtime worked perfectly on Avalonia 0.9.12, so I guess it should work on Avalonia 0.10.0? Or, probably there is a workaround that could help prevent the style resetting after doing _window.Styles[0] = new StyleInclude? Currently using this class and avares for theme loading. Possibly related https://github.com/AvaloniaUI/Avalonia/issues/5509
Desktop (please complete the following information):
- OS: Ubuntu KDE
- Version 18.04 LTS
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)

Top Related StackOverflow Question
Ideally we should somehow debug and fix this on Avalonia side. The issue seems to arise due to a missing key in the dict https://github.com/AvaloniaUI/Avalonia/blob/554aaec5e5cc96c0b4318b6ed1fbf8159f442889/src/Avalonia.Controls/Generators/ItemContainerGenerator.cs#L65-L78
Yeah that’s what I think. I removed my PageSlide transition and can’t make it crash now. I suppose this should also fix it for you.