Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

MoXAML goes MefXAML

0.00/5 (No votes)
6 Sep 2011 1  
MoXAML Power Toys gets that MEF injection to make it plugin based.

First of all, I must apologize that it’s taken me so long to release the new version of MoXAML. Unfortunately, it’s taken a back burner to other projects that I have going on, so it’s been lower down on my priority list than I would have liked. Saying that, I have been tinkering with a new version and making changes to the internal architecture to make it easier for me to add new functionality to it. MoXAML has now got the MEF mojo underpinning it.

A feature of the original version of MoXAML that I was never happy with was the way I had to register commands so that they will appear in the menus. To be honest, the code was a complete mess and it offended my sensibilities whenever I looked at it. Well, the new version has completely changed that. I’ve added a MoXAML.Infrastructure library that provides a lot of the underpinnings of MoXAML registration; all we need to do is derive from the CommandBase class in this library and with just a couple of commands, we are good to go.

First of all, we need to add a unique command name, the menu text and the parent command that we want to show this command in. This just gets added into the constructor likes so:

public MyConstructor()
{
  CommandName = "MyUniqueCommandName";
  Caption = "Menu text";
  ParentCommandBar.Add(CommandBarType.SolutionContextMenu);
}

Now, to add the code to actually do the work, just override the Execute method and add in the functionality that you want to perform.

In a future post, I’ll cover creating an add-in from scratch and talk about the API that’s now been exposed in MoXAML. To get the latest version of MoXAML, please check it out here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here