如何禁用UWP WebView2的拖放功能?

问题描述 投票:0回答:1

在我的 uwp 应用程序中,我使用 webview2(来自 Microsoft.UI.Xaml.Controls)。 并且其中显示的网页内容可以拖放。 我想禁用这个拖放功能,尝试了很多方法,但都失败了。 例如。

AllowDrop="False" CanDrag="False"

有什么想法吗?

xaml:

xmlns:controls="using:Microsoft.UI.Xaml.Controls"

 <controls:WebView2 x:Name="_WebView2" Height="370" Width="792"
     NavigationStarting="WebView2_NavigationStarting"/>

C#:

await _WebView2.EnsureCoreWebView2Async();
_WebView2.CoreWebView2.Navigate(sourceStr);
c# windows uwp
1个回答
0
投票

试试这个:

await _WebView2.EnsureCoreWebView2Async();
_WebView2.CoreWebView2.Controller.AllowExternalDrop = false;

它在我的测试应用程序中有效 您可以查看文档

© www.soinside.com 2019 - 2024. All rights reserved.