MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: Capture MouseWheel and PreviewMouseWheel events in EdgeWebview2 wpf app
Open
@Badhri is already working on this.
Since Feb 13, 2025.
bug
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
I am unable to capture and handle MouseWheel and PreviewMouseWheel events in Edge WebView2 WPF app.
I am pressing (Ctrl + Mouse wheel scroll) and c# app is not capturing the events.
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
133.0.3065.59
SDK Version
1.0.3065.39
Framework
WPF
Operating System
Windows 10
OS Version
10.0.19045.5371
Repro steps
Code to reproduce:
using Microsoft.Web.WebView2.Core;
using System;
using System.Windows;
using System.Windows.Input;
namespace WpfApp
{
public partial class MainWindow : Window
{
private double zoomFactor = 1.0;
public MainWindow()
{
InitializeComponent();
InitializeWebView();
}
private async void InitializeWebView()
{
await webView.EnsureCoreWebView2Async(null);
webView.CoreWebView2.Navigate("https://example.com"); // Replace with your desired URL
}
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{
// Check the direction of the scroll
if (e.Delta > 0) // Scrolling up
{
ZoomIn();
}
else // Scrolling down
{
ZoomOut();
}
// Mark the event as handled to prevent further processing
e.Handled = true;
}
private void ZoomIn()
{
zoomFactor += 0.1;
webView.CoreWebView2.ZoomFactor = zoomFactor;
}
private void ZoomOut()
{
zoomFactor = Math.Max(0.1, zoomFactor - 0.1); // Prevent zooming out too much
webView.CoreWebView2.ZoomFactor = zoomFactor;
}
}
}
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.