MouseEnter event not working RRS feed

  • Question

  • Hey all,

    For some reason I can't get my MouseEnter event to work when I try to set an addEventListener to my object. Here's my code:

    if (!window.buttontest1)
     buttontest1 = {};

    buttontest1.Page = function()

    buttontest1.Page.prototype =
     handleLoad: function(control, userContext, rootElement)
      this.control = control;

      this.Button1 = rootElement.findName("Button1");
      this.Button1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));

     // Sample event handler
     handleMouseEnter: function(sender, eventArgs)
      // The following line of code shows how to find an element by name and call a method on it.


    The only way I can get this to work is if I change

    this.Button1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));


    rootElement.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));

    but that activates the mouseEvent function for an area equal to the size of the entire artboard. Why isn't this working?

    Wednesday, April 9, 2008 1:05 PM


  • Does the button element have a background color? It could be a background with an alpha channel with value 0, but you have to have something in the background for the onmouseenter to react. At least sometimes I've found it to be like this... It's just a thought. If the Button1 element doesn't have a background or content, try adding a background color such as #00000000. Might be that alpha=0 doesn't work by the way...in that case try #01000000
    Would be helpful to see the xaml as well...

    Thursday, April 10, 2008 5:33 AM