MoXAML Power Toys

MoXAML Power Toys

Current version: 2.5.
Released: 12th August 2009.

Introduction

MoXAML Power Toys is a Visual Studio AddIn that’s designed to make your coding that bit more productive for WPF/Silverlight applications.

I started writing MoXAML, partly because I wanted to address some of the features that I needed to be productive in WPF, but also as a complementary product to Karl Shifflett’s wonderful XAML Power Toys. Karl’s stated aim is to produce a tool that quickly and efficiently enables you to write LOB applications in WPF and Silverlight. My aim is to produce a tool that allows you to code with the minimum of effort in Visual Studio.

Downloads

After downloading, you’ll need to change the extension from .doc to .zip. This is a requirement of WordPress.com

Installer – no source:  MoXAML Power Toys_Setup

Source code: MoXAML Power Toys Source

So, what can you do with MoXAML?

BabelCode

With BabelCode you can instantly convert your VB code into C# and vice versa, how cool is that. Simply run BabelCode on your source code and it’s instantly converted.

BabelCode-menu

BabelCode menu in operation.

BabelCode-output

Here’s the converted output from a BabelCode run.

Extract user control

There have been times when I’ve been working on a piece of XAML and I’ve thought, “That would be really handy if it was a control – I could use it in so many places.” Well, with this feature, you can extract XAML and create a user control from it.

UserControl-menu

Here I’ve highlighted the items that I want to convert into a user control.

UserControl-window

At this point, we enter the name of the control we want to create.

UserControl-code

And here’s the control – added into our solution.

Scrubber (updated)

Srubber is a port of Robby Ingebretsen’s scrubber feature in Kaxaml. If you haven’t tried Kaxaml out, then you are missing a treat.

Scrubber performs a “beautify” on your XAML items. It’s called from the Solution menu – just click on one of your source files, choose the Scrubber options and sit back as it works its magic on all of the XAML files in your solution.

Here’s a typical piece of XAML:

XAML before beautification

We choose Scrubber from the menu, and the scrubber dialog appears:

scrubber2

scrubber3

Here’s the same piece of code from above – after it’s been scrubbed:

scrubber4

Note:

Since originally posting Scrubber, a number of people have contacted me to tell me that there was a bug in the original Scrubber code where special characters in XML were being screwed up. Well, Scrubber has been updated to correct this bug – your special characters are now preserved.

Keyword search

Highlight a word in the source and select Lookup keyword from the menu, and voila – a Google and Live search are performed based on the keyword (using the appropriate language type as well).

Menu in action

Commenting

Well, currently you can comment your XAML code and it works OK if you do it once, but if you then attempt to comment over the block again, you get some problems. The following picture shows what the problem actually is.

It doesn’t look too good does it? The first Power Toy, the Comment command behaves slightly differently:

As you can see, multiple comments and it continues to behave. So, that’s the Comment command – I hope you like it.

The sister command of the Comment command is the Uncomment command, and it works it’s way back up through the comment tree to uncomment the commands.

Notify properties

Automatic properties are great, but they don’t play nicely with two way data binding. Now it’s simple to convert an automatic property to use INotifyPropertyChanged. All you need to do is pick the property in the code window and select Notify Property (C# Only), and it will add the necessary plumbing.

Cunningly enough, it adds the Changed method if it’s not already present. ;->

Notify Property in action:

After the command:

The AppWizard

This command allows you to add a status bar, toolbar and menu to your application.

Calling the AppWizard

The AppWizard brings up a dialog where you choose whether or not you want to see a toolbar, a menu or a statusbar. If you choose to add a toolbar or menu, you even get standard icons added into your project. The CommandBindings and App.Resources are set up for you, and the relevant user controls are added into your main window. The statusbar hooks up to the Caps Lock, Scroll Lock, Insert and Num Lock keys to reflect the state of them. It also adds in a date and time which updates every second. I love WPF.

 

The AppWizard in action

The AppWizard in action

Behind the scenes, some of the code injected into your application is C#, but being a nice chap I’ve added a converter in there which translates the C# to VB.NET before it gets added to your project if it detects that your project is VB.NET.

Dependency Properties

One of the banes of my life, is typing in boilerplate code – and boy is there a lot of it with Dependency Properties. Well – that’s about to end. The Create Dependency Property command lets you create an ordinary DP or Attached DP (or readonly versions) with a minimum of effort. Better still, it provides method implementations for you as well – and it does this in both C# and VB.NET.

Selecting the menu (from inside the code editor window) brings up a dialog to enter the core information that you need to create the DP. When you enter the default value, you need to put it in “exactly” as you would if you entered it manually. This means that you must put quotes around it if that’s what is expected by the datatype.

dp-window

The Create Dependency Property window

When you choose Create, the relevant code gets added into the class.

Add FieldModifier

This command searches through your project for XAML files which have x:Name set without setting a FieldModifier. If it finds any entries like this, it adds the x:FieldModifier = “private” attribute. I’d like to thank Josh Smith for providing the inspiration for this command – please see this blog post for more information.

To use this command, right click in the Solution Explorer and choose MoXAML Power Toys > Add FieldModifier.

In conclusion

As always, keep your comments and requests coming in. No idea goes unconsidered.

  1. November 3, 2008 at 2:01 pm | #1

    Pete,

    You are brining the heat!!

    Very nice sir!

    Cheers,

    Karl

  2. peteohanlon
    November 3, 2008 at 2:15 pm | #2

    Thanks Karl – I’m proud of this one, especially as it removes so much room for boilerplate error.

  3. November 7, 2008 at 4:45 am | #3

    Wow Pete! I’ve been outta touch for a while but this is great! The new DependencyProperty creator is exactly what I’ve been waiting for!

    One question–what does the Dependency Property (C# only) command do? I couldn’t figure it out and it doesn’t seem to do anything if I select it.

  4. peteohanlon
    November 7, 2008 at 9:18 am | #4

    Logan – I talk about this one in this blog: http://peteohanlon.wordpress.com/2008/10/07/moxaml-20-released/. It’s code that was created by somebody else for the addin, and one that I might end up beefing up because it currently only puts items on the clipboard – as I’m manipulating the classes anyway, I might use it to populate the class directly.

  5. Joeq
    February 4, 2009 at 3:26 am | #5

    Download ain’t working for some reason.

    • peteohanlon
      February 6, 2009 at 8:40 pm | #6

      Joeq – try now. WordPress was playing a bit funny with the settings.

  6. Joeq
    February 8, 2009 at 3:28 am | #7

    Thanks, that worked.

    • peteohanlon
      February 8, 2009 at 10:03 pm | #8

      Cool – I’m glad it worked.

  7. February 22, 2009 at 10:57 pm | #9

    Really cool power tools … thanks !!!

    • peteohanlon
      February 23, 2009 at 8:44 am | #10

      Thanks El Bruno. I’m glad you like it.

  8. Flo
    February 23, 2009 at 10:55 am | #11

    Hey Pete! Thanks a lot for the scrubber! Great stuff!
    Only have one problem:
    If “&” (without quotes) appears in a text property, the “amp;” is removed.
    Is that intended?

    • peteohanlon
      February 23, 2009 at 10:59 am | #12

      Nope – that’s a bug. I’ll have a look into this – thanks for the feedback.

  9. February 24, 2009 at 9:41 am | #13

    Cool stuff Pete

    • peteohanlon
      February 24, 2009 at 9:46 am | #14

      Thanks Sacha – I hope it helps.

  10. March 6, 2009 at 12:51 am | #15

    I really like the scrubber! I’ve used it a lot in Kaxaml and I’m happy to be able to use it in VS. One issue with it is that it does not handle special character sequences very well, like 
. This add a line break in a string. I reported this to Kaxaml, but he was to busy writing the next version to address. With your port to VS, is this fixed or do the same issues occur?

    Thanks again

    • peteohanlon
      March 6, 2009 at 9:52 am | #16

      @viking
      The same issues exist – I ported the code pretty much “as is” and massaged it to work with Visual Studio projects. I’ve been made aware of this issue since I released MoXAML, and I will be looking to fix the code – I’ll pass the fix back to be put into KaXAML while I’m at it.

      I’m glad you like it though.

  11. Pete
    August 13, 2009 at 9:55 am | #17

    Uh, it’s cool. Is there any way to get this working under VS2010?

    • peteohanlon
      August 13, 2009 at 10:18 am | #18

      @Pete – I haven’t tried to get this running in VS2010 yet. It’s something I will be looking at sometime in the future, but I’ve got no plans to do it yet.

  12. August 14, 2009 at 10:05 am | #19

    Wow Pete, nice work!

    • peteohanlon
      August 14, 2009 at 10:17 am | #20

      Thanks Daniel – I’m glad you like it.

  13. Les Prigmore
    September 23, 2009 at 11:36 pm | #21

    Using MS Vista SP2, VSTS2008 ENU SP 1 (KB945140)

    I installed MOXaml power Toys 2.5. Went to Tools->Options->Environment & added “C:\Program Files (x86)\Lifestyle Computing Ltd\MoXAML Power Toys” clicked OK; then went to Tools\Add-in Manager and checked MoXAMLPowerToys and clicked OK.

    I get the messaage:

    The Add-in ‘MoXAMLPowerToys’ failed to load or caused an exception.
    Would you like to remove………

    Error Message: The system could not find the file specified.
    Error number: 80070002

    However, there is a file named “C:\Program Files (x86)\Lifestyle Computing Ltd\MoXAML Power Toys\MoXAMLPowerToys.AddIn”

    I would like to get MoXAMLPowerToys working because it looks very useful. Any ideas about what might be going wrong?

    Thanks,
    Les Prigmore

    • peteohanlon
      September 25, 2009 at 9:23 am | #22

      Les – you shouldn’t have to add the addin manually – the installer takes care of this for you. I’d suggest that you remove the entry, uninstall the addin and then reinstall it. Hopefully this will sort this issue out for you.

  14. October 27, 2009 at 5:33 am | #23

    Pete,

    Just checking in. You have done so much. Fantastic work!

    Cheers,

    Karl

    • peteohanlon
      October 27, 2009 at 2:07 pm | #24

      Thanks Karl – I appreciate your continuing interest;->

  1. November 2, 2008 at 9:25 pm | #1
  2. February 22, 2009 at 9:22 pm | #2
  3. February 23, 2009 at 4:47 am | #3
  4. February 24, 2009 at 6:10 am | #4
  5. July 2, 2009 at 8:06 pm | #5
  6. July 27, 2009 at 9:51 pm | #6
  7. September 8, 2009 at 5:12 pm | #7