Skip to content

DataTransferManager and Share API #970

Description

@Marv51

Describe the bug
In WinUI 2 I had a "Share" functionality to share an image with Windows 10 system APIs. DataTransferManager has an event called DataRequested that you need to subscribe to that makes this work.

In WinUI3 with CsWinRT this is pretty difficult, because you need to get your `DataTransferManager from IDataTransferManagerInterop, like this:

using Windows.ApplicationModel.DataTransfer;
using Windows.Win32.UI.Shell;

var guid = Guid.Parse("a5caee9b-8708-49d1-8d36-67d25a8da00c");
var iop = DataTransferManager.As<IDataTransferManagerInterop>();
var manager = iop.GetForWindow(GetMainHwnd(), guid);
var dtm = manager as DataTransferManager; // cast is always null here, I believe manager should be cast to an interface, but no interface for DataTransferManager exists.

However, it is unclear to me how to use that returned object. I can't cast to a DataTransferManager, maybe because that would only work with an interface? But DataTransferManager does not have any interface in the API docs.

I'm getting the IDataTransferManagerInterop from CsWin32, I asked on their repo, but no solution could be found.

Is this a projection issue with CsWinRT, or should I be asking somewhere else?

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions