Access to ImageBrush from Javascript
i hava problem , can not find how solve it.
i created grid of rectangles 'grass' image imagesource javascript dynamically (20 20). now, i want change source of picture when mouse enters region of rectangle. don't know how i can it. event handle for this mouseenter wich calls 'mouseentertilehandler(sender, args)'
the following code gets executed in loop:
var
tile = control.content.createfromxaml('<rectangle stroke="black" strokethickness="0.5" \ mouseleave="mouseleavetilehandler" mouseenter="mouseentertilehandler" height="25" width="25" \canvas.zindex="1" canvas.top="' + * 25 + '" canvas.left="' + j * 25 + '"> \<rectangle.fill> \
<imagebrush imagesource="images/grass.jpg"></imagebrush> \</rectangle.fill> \
</rectangle>'
);is possible query sender , change imagesource of imagebrush relevant rectangle? if so, how set then? know can change value of attached property this way: sender["canvas.top"] = xx. the imagesource in my situation is property of imagebrush , imagebrush itself is child element of rectangle.fill wich child element of rectangle. how can access sender argument? need sort of eventbubbling other way :p
another solution can think of naming imagebrush. problem have that i don't know how i can relevant name of rectangle.
i hope made myself understandable , can me.
silverlight fun :)
good evening....
since you're in loop bulding this, why not set x:name of rectangle loop indice? ... or if don't have need of index, generate 1 purpose.
then imagebrush named whatever index + "_brush" instance.
so when mouseenter, name of sender, going numerical value name of rectangle, such "18", , know brush "18_brush".
i've used in bunch of things i've got running.
we can keep kicking around if that doesn't help...
-dave
Silverlight > Programming Silverlight with JavaScript
Comments
Post a Comment