-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Description
In JavaScript there are events such as ondrop, ondragover, ondragstart, and the property draggable, which are used together to enable drag/drop functionality in HTML-based apps.
On WinUI WebView2 these do not seem to function correctly and the ondragover event doesn't seem to fire (perhaps because the drag was never really started). On WPF WebView2 this works fine.
To see a sample of drag/drop, go to this sample: https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop
Version
SDK:
- WinUI: Windows App SDK 1.1.5
- WPF: NuGet 1.0.1343.22
Runtime: 105.0.1343.33
Framework: WinUI and WPF
OS: Win11
Repro Steps
For WinUI:
- Create new WinUI app
- Replace the code in MainWindows.xaml.cs with this:
public sealed partial class MainWindow : Window { public MainWindow() { var wv = new WebView2() { Source = new Uri("https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop"), }; Content = wv; } }
- Run the app and you should see a UI like this, but when you try to drag the image, it is not draggable (it does nothing):

Expected: The drag/drop operation should work exactly as it does when you navigate to the site in Edge or any other browser.
Interestingly, in the same example in WPF as you drag the image up, you can see it being dragged, and then you can drop it into the box. WPF repro steps:
- Create new WPF app
- Add NuGet reference to Microsoft.Web.WebView2
- Replace the code in MainWindow.xaml.cs with this:
public partial class MainWindow : Window { public MainWindow() { var wv = new Microsoft.Web.WebView2.Wpf.WebView2() { Source = new Uri("https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop"), Width = 400, Height = 400, }; Content = wv; } }
- Run the app and try to drag/drop the image on the right, and it works:

Originally reported in this .NET MAUI issue: dotnet/maui#9983