Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

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

Open
berryjordaan opened this issue Feb 24, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@berryjordaan
Copy link

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.

#286 (comment)

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

@berryjordaan berryjordaan added the bug Something isn't working label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants