How to Bind the Service Manager Authoring Tool’s Form Controls in Visual Studio

Author by Christopher Mank

In my last blog post "How to Add the Service Manager Authoring Tool’s Form Controls to Visual Studio," I showed you how you can add the Service Manager Authoring Tool's (AT) form controls to Visual Studio.  In this post, I am going to show you how to properly bind those objects. There is plenty of documentation on the web on how to properly bind WPF controls, but what about SM controls?  Well I have a hint for you.  If you are unsure about how or where to bind SM controls in your Visual Studio form project, you can use the AT to see how the binding is implemented. To demonstrate, I created a new test Management Pack (MP) and called it TestMP.  I then created a new form in the MP and named it TestForm.  For our demonstration, I will show the binding for the User Picker, Single Instance Picker and List Picker controls. 1.  Add a User Picker, Single Instance Picker, and List Picker control to the form.  Don't worry about any of the aesthetics.  All we care about is the XML, which we'll see in a minute. 2.  We need to bind these controls to a property or relationship.  Since all we care about is how they are binded and not what they are binded to, I just went ahead and binded them to any property or relationship by setting the Binding Path. User Picker: Single Instance Picker: List Picker: 3.  After saving the form, open up the MP XML.  When modifications are made to the form, each customization is saved to the MP.  When we set the Binding Path on each of the above objects, this customization is also saved to the MP.  When a new binding is created to a related object, the AT automatically creates the needed Type Projection.  To makes things easier, I've renamed the Alias to something more readable. As you can see from the below screenshot, the AT keeps track of the control's property where the binding is stored.  For example, on the User Picker, the binding is stored on the User property.  On the List Picker, the binding is stored on the SelectedItem property.  The binding information also indicates the Path where the relationship can be found.  This relates back to the Type Projection automatically created by the AT (shown above). 4.  With the information above, you can now create your custom form using Visual Studio and bind the SM controls using the correct properties. I hope this helps! Until the Whole World Hears, Christopher
Author

Christopher Mank

Systems Architect