Closed
Description
openedon Apr 16, 2021
Describe the bug
This is a frequent and basic drag & drop scenario. In a WinUI 3 Desktop app, when dragging an element that contains DataPackage, there is a InvalidCastException because it was no possible to cast DataPackage to DataPackageView. This was working in UWP with .NET Native before.
Here is the exception:
System.InvalidCastException: Unable to cast object of type 'Windows.ApplicationModel.DataTransfer.DataPackage' to type 'Windows.ApplicationModel.DataTransfer.DataPackageView'.
at WinRT.ComWrappersSupport.CreateRcwForComObject[T](IntPtr ptr)
at WinRT.MarshalInspectable`1.FromAbi(IntPtr ptr)
at Windows.ApplicationModel.DataTransfer.DataPackageView.FromAbi(IntPtr thisPtr)
at ABI.Microsoft.UI.Xaml.IDragEventArgs.global::Microsoft.UI.Xaml.IDragEventArgs.get_DataView()
at Microsoft.UI.Xaml.DragEventArgs.get_DataView()
To Reproduce
-
Clone this repository.
-
Try to drag the First Label element or the Another Label element into the TreeView.
-
You will observe the Exception in the Output window. Feel free to place some breakpoints when capturing the exception.
Expected behavior
Work nicely and beautiful showing up even the pictures (a rendered text of First Label or Another Label)
Version Info
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.5" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.5.5" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.5" />
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="1.2.2" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment