I have a Windows Forms application, which has one WPF user control, available through ElementHost control.
The WPF user control has code designed to respond to mouse wheel events. However none of the code written associated with these events is running in the wpf when I run the application and I use the mousewheel. I tested this by placing breakpoints in the visual basic code. Despite this, it does respond to other mouse events (such as click or drag, which I use to do rotation of my 3d model).
I was wondering that maybe the mousewheel events are not passing from the Windows Forms, to the WPF user control, because windows forms as no (or limited) mousewheel support.
In contrast, I tried to write a simple program of a WPF user control inside a WPF application, and this control responds to the mousewheel events.
The WPF usercontrol has a viewport3D, which I use to do some 3d drawing, which can't be done in Windows Forms.
Is there a workaround to this problem? I hope you can help. Thank you.
Here is an example of how I setup the Mousewheel event in the WPF control. I tried within the UserControl, Grid and Canvas, but I get no mousewheel events in either of them.
<UserControl x:Class="LPViewport3D"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Background="white" MouseMove="UserControl_MouseMove" MouseDown="UserControl_MouseDown" MouseWheel="UserControl_MouseWheel">
<Grid MouseWheel="Grid_MouseWheel" Background="white">
<Viewport3D x:Name="VP" Margin="0" ClipToBounds="False" Grid.Row="0" Grid.Column="0" >
<!-- more code -->
</Viewport3D>
<!-- Ovelay canvas to receive mouse events-->
<Canvas Grid.Row="0" Grid.Column="0"
Background="Transparent"
MouseDown="Canvas_MouseDown"
MouseMove="Canvas_MouseMove" MouseWheel="Canvas_MouseWheel" />
</Grid>