In native UWP apps, we can show share UI by calling DataTransferManager.ShowShareUI method.
DataTransferManager.ShowShareUI();
Calling this method in a desktop bridge app raises an exception:
Element not found.
This method cannot be called while the app is in the background
That's kind of expected as the bridge app does not use the UI elements of UWP. So I tried to use way it should be done in native Win32 apps.
In native Win32 apps, we can show share UI by calling DataTransferManagerHelper.ShowShareUIForWindow method. However, this call in a desktop bridge app (that runs in an app context) does nothing but crashing explorer.exe
. The exact same code works if the app does not run as a bridge app but as a native Win32 app.
IntPtr hwnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
DataTransferManagerHelper.ShowShareUIForWindow(hwnd);
Any help is appreciated.
Update
This issue has been fixed on build 17024. I successfully ran the code to open share UI on the latest insider build (17101).