Image MouseDown事件未触发 [英] Image MouseDown event not firing

查看:177
本文介绍了Image MouseDown事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个用户的电脑上有一个问题,在那里她无法点击图像(好吧,她可以点击它,但没有发生任何事情)。该图像具有以下XAML:

 < Image Source =./ Images / flag.jpg
名称=image1
Stretch =Uniform
Height =40
Horizo​​ntalAlignment =Right
VerticalAlignment =Top
ImageFailed =image1_ImageFailed
Mouse.MouseDown =RotateImage
Margin =0,0,0,0
Cursor =Hand/>

MouseDown事件由以下方式处理:

  private void RotateImage(object sender,MouseEventArgs e)
{
//某些代码...
}

每个其他用户(其中​​有50个以上)可以点击图片并正确执行事件背后的代码。另外,当我登录到PC(在我的用户名下)时,我可以点击该图像并使代码执行正常。她正在运行XP,这是.Net 3.5应用程序。



此外,当鼠标悬停在图像上时,光标从箭头更改为手。 p>

我尝试过以下操作来缓解此问题:




  • >设置 - >控制面板 - >系统 - >高级 - >性能 - >设置:在此之下,我尝试了所有不同的单选按钮和复选框的各种组合。没有任何工作。


  • 我已经尝试将其从双显示器更改为单个显示。没有运气。


  • 我尝试了各种分辨率设置,但没有改变结果




    • 她似乎有一个自定义设置,阻止将此事件路由到代码,但我找不到它。任何建议将非常感谢。



      谢谢!

      解决方案

      好的,在做了JustABill提出的一些测试之后,看起来我是错误的。该应用程序响应mousedown事件。但是,按钮后面的代码是响应应用于图像控件的图像文件的名称(并且在某些情况下更改图像文件)。问题是某些用户的PC无法识别初始图像文件的名称(由程序员分配为默认的文件),而其他用户的名称是。此外,我看到一个用户的PC,首先没有功能的麻烦。但是在几个小时后运行一些额外的测试,它会退出工作(没有安装任何更新)。这是一个奇怪和不一致的问题,但是如果无法识别当前应用的映像文件的名称,我可以通过实现一些默认功能将新的映像文件重新分配给映像控件来解决。感谢Wallstreet Programmer和JustABill,以促使我尝试一些新的东西!



      约翰


      I have a problem on one of my user’s PC’s where she cannot click on an image (well, she can click on it, but nothing happens). The image has the following XAML:

      <Image Source="./Images/flag.jpg" 
             Name="image1" 
             Stretch="Uniform"
             Height="40"
             HorizontalAlignment="Right" 
             VerticalAlignment="Top" 
             ImageFailed="image1_ImageFailed" 
             Mouse.MouseDown="RotateImage" 
             Margin="0,0,0,0"
             Cursor="Hand"/>
      

      And the MouseDown event is handled by:

      private void RotateImage(object sender, MouseEventArgs e)
      {
          //Some Code…
      }
      

      Every other user (there are 50+ of them) can click on the image and properly execute the code behind the event. Also, when I log into her PC (under my username), I am able to click the image and have the code behind execute properly. She is running XP, and this is .Net 3.5 app.

      Also, when her mouse hovers over the image, the cursor changes from an arrow to a hand.

      I have tried the following to alleviate this issue:

      • Start->Settings->Control Panel->System->Advanced->Performance->Settings: Under this I have tried all the different radio buttons, and a variety of combinations of the checkboxes. Nothing worked.

      • I have tried changing it from a dual display to a single display. No luck.

      • I have tried various resolution settings, but they didn’t change the outcome

      There appears to be a custom setting for her that is preventing the routing of this event to the code, but I cannot find it. Any suggestions would be very much appreciated.

      Thanks!

      解决方案

      Okay, after doing some of tests that JustABill suggested, it looks like I was mistaken. The application was responding to the mousedown event. However, the code behind the button was to respond to the name of the image file applied to the image control (and change image files in certain circumstances). The problem was that certain users’ PC’s were not able to recognize the name of the initial image file (the one assigned as default by the programmer), while others’ were. Also, I watched one user’s PC who had no trouble with the functionality at first. But upon running some additional tests a few hours later, it quit working (without having installed any updates). It’s a strange and inconsistent problem, but I was able to get around it by implementing some default functionality that reassigned a new image file to the image control if it doesn’t recognize the name of the image file presently applied. With that, everything started working properly.

      Thanks to Wallstreet Programmer and JustABill for prodding me to try some new things!

      John

      这篇关于Image MouseDown事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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