我正在尝试在 Windows 窗体中使用画布并为此缩放和平移该画布我首先放置元素主机,然后将画布放在其中,然后将图片框放在画布中,然后尝试缩放画布我尝试了各种方法,但任何事件控件未执行我还编写了所有鼠标滚轮事件,但没有一个被执行所以请建议我下面的解决方案是我添加控件和鼠标滚轮事件的代码
elementHost1.Height = picVarify.Height;
elementHost1.Width = picVarify.Width;
elementHost1.Location = picVarify.Location;
touchcanvas = new System.Windows.Controls.Canvas();
WindowsFormsHost hst = new WindowsFormsHost();
hst.Name = "Host";
hst.Child = picVarify;
hst.Height = picVarify.Height;
hst.Width = picVarify.Width;
touchcanvas.Height = picVarify.Height;
touchcanvas.Width = picVarify.Width;
touchcanvas.Children.Add(hst);
zm = new ZoomAndPan.ZoomAndPanControl();
zm.Name = "zm";
zm.Content = touchcanvas;
zm.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(zoomAndPanControl_MouseWheel);
elementHost1.Child = zm;
touchcanvas.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(touchcanvas_MouseWheel);
hst.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(hst_MouseWheel);
picVarify.MouseWheel += new MouseEventHandler(picverify_MouseWheel);