none
Blend 2.5: document.getElementByName to pick up object names from XAML file? RRS feed

  • Question

  • Using Blend 2.5 - Silverlight 1.0 Website

    my handleload function automatically generated by Blend works fine, except I've changed it slightly. I have two objects grouped into two canvases on my page and they exist one on top of the other. I want to add an event listener for the top level object only. When I use

    rootElement.addEventListener("MouseLeave", etc...)

    it works but it's also targeting the second object behind the first, which animates as a storyline and comes out from behind the first when the mouse is hovered over the first object. So I want the second storyline to play only when the mouse leaves the first object. I'm using:

    var ele1 = document.getElementByName("Outside"); 
    ele1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
    ele1.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));

    in my Page.xaml.js document and in my page xaml document I have the canvas defined:

    <Canvas Canvas.Left="8" Canvas.Top="108.334" Width="144.553" Height="189.578" x:Name="Outside">

    When I hover the mouse over the object named "outside" the handleMouseEnter function is supposed to be hit, which is this:

    handleMouseEnter: function(sender, eventArgs)
     {
      this.control.content.findName("OpenBox").Begin();
     },

    but it never happens. The problem is that document.getelementbyName or document.getelementbyID doesn't pick up the name of the Canvas object in my XAML file. How can I reference the objects from the XAML file by name so I can pick them up individually instead of by "rootElement" which picks them all up at once?

    Will
    Friday, April 17, 2009 4:59 PM
    Moderator