CommandBarControl Click Event is not Working!!!!

2. September 2012 00:15 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)

Today I was doing a VS extention as part of my weekend relaxation activities ;)

Everything was great until succendly something was not happening as I expected.

 I was adding a context menu to the code window with a dynamic list of options.

And each option had a different click delegate, but my click events were

disrespectfully discarted.

 Luckily I found this post:  http://www.rauchy.net/blog/?cat=4&paged=2

 And now for a tricky part: since you ge\t your instance of CommandBarEvents inside the scope of a method, when the method ends, the Garbage Collector collects it, leaving all the event handlers orphaned. Unless you keep your instance safe from the jaws of the mighty Garbage Collector, your buttons will not respond to clicks.

To do so, just keep your CommandBarEvents instance(s) as member fields of your class. Once your class is disposed, they will be disposed as well.

 Thanks Rauchy you saved my day! (And my wife is happy because I'm finally getting out of the bathroom :P)

How to create an adding that add context menu for certain files types in Visual Studio

21. October 2010 03:29 by Mrojas in   //  Tags: , , , , , , , , ,   //   Comments (0)

Recently I was looking for a way to create an Adding that will add a Context Menu only when I Right Click on .xaml files.

I know there a many ways now, but I still love using VS studio addins for some simple tasks.

In case you are wondering how to do that 

I found this great article: http://davedewinter.com/2008/03/22/dynamic-menu-commands-in-visual-studio-packages-part-2/

Categories