InvalidCastException in ItemsControl with custom container #9855
Labels
area-C#/WinRT
bug
Something isn't working
fix-released
The fix has been in a release (experimental, preview, stable, or servicing).
team-Reach
Issue for the Reach team
Milestone
Describe the bug
Since version 1.6.240701003-experimental2 I'm getting an InvalidCastException in a custom ItemsControl when iterating over its container elements.
Steps to reproduce the bug
MainWindow.xaml:
MainWindow.xaml.cs:
Expected behavior
No InvalidCastException should be thrown
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.6 Experimental 2: 1.6.240701003-experimental2
Windows version
No response
Additional context
This is the stacktrace of the InvalidCastException:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.IObjectReference.As[T](Guid iid)
at System.Collections.Generic.IEnumeratorImpl
1.Make_IEnumeratorObjRef() at System.Collections.Generic.IEnumeratorImpl
1.get_iEnumeratorObjRef()at System.Collections.Generic.IEnumeratorImpl
1.Windows.Foundation.Collections.IIterator<T>.get_HasCurrent() at ABI.System.Collections.Generic.FromAbiEnumerator
1.MoveNext()at System.Linq.Enumerable.d__229
2.MoveNext() at System.Linq.Enumerable.<OfTypeIterator>d__66
1.MoveNext()at System.Collections.Generic.List
1..ctor(IEnumerable
1 collection)at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TestWinUI.CustomItemsControl.TestControl_Loaded(Object sender, RoutedEventArgs e) in D:\Repos\TestWinUI\TestWinUI\CustomItemsControl.cs:line 18
at WinRT._EventSource_global__Microsoft_UI_Xaml_RoutedEventHandler.EventState.b__1_0(Object sender, RoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.RoutedEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)
The text was updated successfully, but these errors were encountered: