问题
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).
回答1:
I have confirmed that this is a bug. ShowShareUIForWindow() would be the right API to call for your scenario, once the bug is fixed.
I have assigned the bug to the right team now.
Thank you for reporting the issue!
Update
Fix is available in build 17024 and above
来源:https://stackoverflow.com/questions/46327238/unable-to-show-share-ui-in-desktop-bridge-app