Right-Clicking in Silverlight 2 — A Refinement


First, don’t require the user to write the Javascript every time.  Instead let the Silverlight code execute the javascript that includes the necessary browser functionality.

Second, instead of sending events around, or passing arguments through your user controls, use reflection to find the controls that care about right-clicks.  This is the fun part.  There exists a neat little static method called VisualTreeHelper.FindElementsInHostCoordinates().  You pass it the mouse coordinates, and it returns a list of all of the controls that occupy space at that point.  Then, just find any controls that implement the interface IRightClickable and call the method.

Right-Clicking in Silverlight 2 — A Refinement


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s