Skip to content

Drag&Drop scenario broken because InvalidCastException #807

Closed

Description

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

  1. Clone this repository.

  2. Run the app and you will see something like this:
    image

  3. Try to drag the First Label element or the Another Label element into the TreeView.

  4. 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

Metadata

Labels

bugSomething isn't workingfixedIssue has been fixed in an upcoming or existing release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions