Wednesday, June 25, 2008
« Geek dinner | Main | UML + DSL »

So, I am building a Silverlight 2 application related to my trip to Klipsch in Indianapolis this year, and found what seems to be to be a terrible bug in Silverlight 2 beta 2.  Multiple UIElements  cannot share event handlers.  What do I mean?  In my case, I have varous Paths inside a canvas and I'm creating hotspots.  When the mouse enters a given region, something slightly different will happen, however the exact same method is called for every single region when the mouse exits that Path.  So, suppose I have a Path called Damon, which happens to have some Damon-y things inside it and I'm going to display my name:

private void _damonPayne_MouseEnter(object sender, MouseEventArgs e)

{

AddCallout("D.R. Payne", "damonrpayne", "Hartford, WI", e);

}

When the mouse exists, I simply remove the UIElement representing the callout, which is the same for all regions on the page:

private void _damonPayne_MouseLeave(object sender, MouseEventArgs e)

{

RemoveOldCallout();

}

Now, it would seem that I could make the functionality in RemoveOldCallout a MouseEventHandler and share the same method among the various paths:

protected void RemoveOldCallout(object sender, MouseEventArgs e)

{

RemoveOldCallout();

}

Now, if I have another Path, I should be able to write code like _someOtherPath.MouseLeave += new MouseEventHandler(RemoveOldCallout);  This code, however, bombs with the following BadPropertyValue error:

 

Now, I have to write a different MouseLeave event for every single path on my page, and there's a lot of them.  I'll submit to Connect and hope this issue is fixed!

Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview