views:

244

answers:

2

Hi all I am new in silverlight. I want to use context menu in treeview item in my silverlight 3 application . I have searched in the net regarding this I have found my custom application for this but I am not getting them .How to use context menu, how to add rightclick event for using context menu .

Thanks in addvance

+1  A: 

If you must do this immediately then this blog article describes how to use the plugin in windowless mode an then borrow the host broweser oncontextmenu event to detect the right mouse button. However I would hold off if you can and use Silverlight 4 which supports context menus directly. Its best to avoid windowless mode if you can.

AnthonyWJones
I am usins silverlight3.I am still not able to set windowless mode in default.aspx to get right click event.
@ashishtri: What prevents you from enabling windowless mode? In Silverlight 3 without Windowless mode you have no hope using a context menu. Is dropping the requirement for a context menu viable? Could you add something clickable to the treeview item content to access the menu?
AnthonyWJones
A: 

I'm using the free context menu from viblend and I open it by doing the following:

  1. Subscribe to the MouseRightButton event

this.Root.MouseRightButtonDown += new MouseButtonEventHandler(Root_MouseRightButtonDown);

  1. Open the Menu in the event handler

Point pt = e.GetPosition(this.Root); pt = new Point(pt.X, pt.Y); this.Menu.Open(pt);

Jane