You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
What happened?
I have successfully set up sharing from my WinUI3 app utilizing the interop functionality. All is working and when I select to share with Microsoft Mail the Data Package is working fine, although the bitmap isn't rendering in the NEW OUTLOOK app.
Although it does work in the OLD OUTLOOK
[System.Runtime.InteropServices.ComImport]
[System.Runtime.InteropServices.Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
interface IDataTransferManagerInterop
IntPtr GetForWindow([System.Runtime.InteropServices.In] IntPtr appWindow,
[System.Runtime.InteropServices.In] ref Guid riid);
void ShowShareUIForWindow(IntPtr appWindow);
static readonly Guid _dtm_iid =
new Guid(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);
public async void WebView_ShareObject(object sender, RoutedEventArgs e)
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow);
IDataTransferManagerInterop interop =
Windows.ApplicationModel.DataTransfer.DataTransferManager.As
<IDataTransferManagerInterop>();
IntPtr result = interop.GetForWindow(hWnd, _dtm_iid);
var dataTransferManager = WinRT.MarshalInterface
<Windows.ApplicationModel.DataTransfer.DataTransferManager>.FromAbi(result);
InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();
await WebViewService.WebView.CoreWebView2.CapturePreviewAsync(CoreWebView2CapturePreviewImageFormat.Png, stream);
RandomAccessStreamReference randomAccessStream = RandomAccessStreamReference.CreateFromStream(stream);
dataTransferManager.DataRequested += async void (sender, args) =>
args.Request.Data.Properties.Title = "Web Dive Sharing";
args.Request.Data.SetText("Sharing your webpage");
args.Request.Data.SetWebLink(new Uri(WebViewService.WebView.CoreWebView2?.Source));
args.Request.Data.SetBitmap(randomAccessStream);
args.Request.Data.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Link;
// Show the Share UI
interop.ShowShareUIForWindow(hWnd);
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
WinUI3/WinAppSDK
Operating System
Windows 10
OS Version
No response
Repro steps
Regression
No, this never worked
Last working version (if regression)
No response
Is the CapturePreviewAsync call working correctly? Does it complete and is the stream filled in with valid PNG data? If your code was working with the old outlook app and not the new outlook app, and the CapturePreviewAsync method is working the same in both then I don't know what the problem might be. But would likely not be a problem with WebView2?
Okay I’ll take your word for it
Ty. Although I did have a problem did u repo. Winui3 get window handle
register data share and then try to both apps. The picture is there but in
new outlook nothing appears. Try my web dive app on Microsoft store and
use the share button I have on my toolbar and not the right click from
webview2