Partilhar via


Creating Addins for XamlPadX

I got a few queries after releasing XamlPadX v3 regarding creating addins for the tool. So here is a small post on it. :)

Create a customControlLibrary project. Add a reference to the AddInView dll present in the XamlPadX folder which is located in the program files folder. Also add a reference to the 3.5 System.Addin dll.

Now in the xaml file change the UserControl Tag into AddInAddInView

<f:AddInAddInView x:Class="customaddin.UserControl1"

xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"

xmlns:f="https://foo"

Height="200" Width="200">

<Grid>

<Rectangle Fill="red" Height="100" Width="100"/>

</Grid>

</f:AddInAddInView>

the namespace is exposed as https://foo/ in the AddInView.dll :) 

 Now for the code behind

    [AddIn("MyAddin", Description="This is my addin", Publisher="MS", Version="1.0.0.0")]

    public partial class UserControl1: AddInViews.AddInAddInView

The usercontrol extends from the AddInAddInView class. Also creating an AddIn attribute makes it readable in the addin dialog. The AddIn attribute takes (AddinName, Description, Publisher, Version).

You will also need to override 2 functions. SendSignal(String) and Initialize(AddInHostView)

The SendSignal just passes a string ("Displaying Addin: Name") from the host to the Addin. In the colorPallete Addin, the function opens a MessageDialog. The function is a demo of host-addin communication.

The Initialize function passes the host object to the addin. The host object provides access to 3 functions.

ChangeAppBackground - changes the background of the xamlpadX app ( you can see this working if you click the last button in the colorpallete addin)

TextBoxCaretIndex - caret index in the editing textbox of the xamlpadX tool. This is helpful if you want to insert some text

textBoxContents - Content of the editing textbox in the tool. This is a get/set property so you can set the entire content of the textbox.

The final part is the placement of the dll. By default the xamlpadX files are placed in ProgramFiles/XamlPadX. There is an Addins folder. Create a folder for you addin and place your dll in this folder (do not place the addinview dll..it already exists). Restart XamlPadX and you should see your addin the Addin dialog.

attached is a sample addin project.

Share this post

 

customaddin.zip

Comments

  • Anonymous
    December 26, 2007
    Great !!! Thanks a lot for the post... I was missing the AddInAddInView - I was creating a Usercontrol instead... Silly me :) I finally managed to create a dummy plugin for XamlPadX WOWOWOW Thanks a lot

  • Anonymous
    January 04, 2008
    Hi, I am working on a plugin for XAMLPadX. Yet I am having a problem when I call the AdornerLayer.GetAdornerLayer on one of my elements.... Can you drop me an email at marlongrech@gmail.com so that we can discuss this... P.S the Plugin will be downlaodable from everyone I will make sure to post a link to the plugin on your Blog... Looking forward to here from you :) Regards

  • Anonymous
    January 09, 2008
    Hello everyone, I wrote a blog post on how to get the Adorner Layer while developing plugins (that use the System.Addin like XAMLPadX does).... If you are using the AdornerLayer.GetAdornerLayer this post should make your life easier... http://marlongrech.wordpress.com/2008/01/09/how-to-get-an-adorner-layer-without-the-use-of-adornerlayergetadornerlayer/ Regards