MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: WebView2CompositionControl in WPF does not work with AllowExternalDrop=true

Open
#5,124 2 comments 0 reactions 1 assignee View on GitHub

@Badhri is already working on this.

Since Feb 27, 2025.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

In the latest version of Microsoft.Web.WebView2, version "1.0.3065.39", the WebView2CompositionControl does not allow Drag and Drop into the WebView2 component.

It does work for WebView2, but not for WebView2CompositionControl. We need to use WebView2CompositionControl to allow the web views to draw underneath other WPF components.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

1.0.3065.39

SDK Version

net472

Framework

WPF

Operating System

Windows 10

OS Version

19045.5487

Repro steps

I created a little app to test the functionality.

MainWindow.xaml

<Window x:Class="AllowExternalDropTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:AllowExternalDropTest"
        xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <DockPanel>
            <wv2:WebView2CompositionControl Name="webView" Source="https://www.google.com" AllowExternalDrop="True" />
        </DockPanel>
    </Grid>
</Window>

AllowExternalDropTest.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net472</TargetFramework>
    <UseWPF>true</UseWPF>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <Optimize>False</Optimize>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3065.39" />
  </ItemGroup>

MainWindow.xaml.cs

using Microsoft.Web.WebView2.Core;
using System;
using System.Windows;

namespace AllowExternalDropTest
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

The app will open Google.
Click on "Search by Image"

Image

Attempt to drag an image into the WebView.

Observe:

Dragging an image is not allowed for upload.

This functionality works fine if using WebView2. However, we need to use WebView2CompositionControl, as we require the webview to draw underneath other WPF elements as per this bug.

https://github.com/MicrosoftEdge/WebView2Feedback/issues/286#issuecomment-2669687779

Test Source Code:

AllowExternalDropTest.zip

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.