需要帮助-自定义画布无法生成鼠标事件 [英] Need help -Custom Canvas Unable to generate Mouse events

查看:112
本文介绍了需要帮助-自定义画布无法生成鼠标事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我不明白为什么自定义画布无法生成鼠标事件.

我已经从Canvas继承了课程.并添加到XAML中.现在,iam无法为画布生成鼠标事件.
请帮助我现在如何为画布生成鼠标事件.

Xaml代码

Hello,

i cant understand why custom canvas is not generating mouse events.

i have inherited class from Canvas. and added in XAML . Now iam unable to generate mouse events for the canvas .
plz help me how to generate mouse events for canvas now.

Xaml Code

 xmlns:local="clr-namespace:Editor1"

<local:Mycanvas
      x:Name="Mycanvas"
      Background="AliceBlue"
      Grid.Column="1"
      Grid.RowSpan="2"
      Margin="-1.72235559148248E-09,30.8125,8,53.8125"
      Width="auto"
      Height="auto"
      MouseLeftButtonDown="Mycanvas_MouseLeftButtonDown"
      MouseMove="Mycanvas_MouseMove"
      MouseLeftButtonUp="Mycanvas_MouseLeftButtonUp">
        </local:Mycanvas>




帆布课




canvas class

public class Mycanvas:Canvas
    {
      // declarations

      public Mycanvas()
        {
          // do something
        }
}



尝试过不同的背景,但仍然无法正常工作?
哪里出问题了?


谢谢



tried with diiferent backgrounds but still not working?
where iam going wrong?


Thanks

推荐答案

一般来说WPF句柄在画笔的帮助下进行命中测试,看来您的背景是透明的,我怀疑这可能是潜在原因,可以检查一下是否更改背景会有所帮助吗?
In general WPF Handles hit testing with the help of brushes, seems you have a transparent background, I suspect it could be a potential cause, can you check if changing the background helps or not?


这篇关于需要帮助-自定义画布无法生成鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆