Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting objects on a WPF canvas?
Message
De
24/02/2009 01:09:49
 
 
À
23/02/2009 22:13:11
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01383557
Message ID:
01383676
Vues:
32
>Are you asking how to find the collection, or how to handle the click.
>
>For finding the collection I would probably store it as a property of the hole.
>
>For the click I would use the PreviewMouseDown event on the ellipse.

So you probably already read my reply where I said I had it working. And it does work perfectly, (except that it requires great precision with the mouse), but I want to ask this: is it really smart to add an event handler to EVERY ellipse that gets added to a canvas? Now I don't know what kind of memory bog that could be, or maybe it is a piece of cake for WPF and Windows to handle.

In a practical case, I guess there would be not more that 30-50 holes even on a screen that had multiple patterns, but still; *FIFTY* event handlers? It just seems scary. And actually, each "Hole" is visually represented by two concentric circles and a text label (see the screenshow here: http://twitpic.com/1f2ci/full ), and I know the user would expect to be able to click on any one of those elements to select a hole. That means an event handler on 3 elements for every hole. Now we could be talking about 100 or more event handlers.

It seems like there should be a solution where you could have just one event handler on the Canvas and read the element reference under the mouse, then work off of the .Tag property of that elment, and so on.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform