views:

21

answers:

1

Hi

I am creating a card game in Silverlight.

Each player has a Hand which contains multiple cards.

A card is a customised button e.g.

public partial class CardButton : Button

When a player has 2 or more cards of the same rank, I want a mechanism to be able to select both of them.

So I have attached a mouse over event to each card, which detects if there is any other card of the same rank in the hand, and if so displays a button with "play both" (or similar) at the position of the cursor

However, in the click event of this button I need to know which cards have been selected

Is this the right way to go?

I am very new to Silverlight so suspect I am missing something

Is there some kind of event biubbling that allows me to detect what is underneath the pressed button?

Do I need to use hit testing? Or is there a simpler way?

Should I use a Popup or Tooltop control instead?

Is there a simple way for me to associate the poped up button with one or more cards?

Would it be stupid to write the rank of a card to a member variable on mouseover, and retrieve that in the click event of the popped up button?

Any Silverlight pros out there got any advice?

many thanks

A: 

Lookup VisualTreeHelper.FindElementsInHostCoordinates.

That returns a list of all items rendered under a specified position (e.g. the mouse cursor pos).

Enough already