Building on my good buddy Christopher's recent blog posts about custom forms in Service Manager (Part 1
, Part 2
) today I'd like to talk about how to add validation to your custom forms. This post assumes you know some of the basics about how to create custom forms using Visual Studio. Also, it is worth pointing out that there are multiple ways to accomplish form validation. Today I'll talk about how to use the validation that is built in to Service Manager.
The first step is to add the necessary assembly as a reference to your project. Specifically, you need to add Microsoft.EnterpriseManagement.UI.FormsInfra.dll, which is located in C:Program FilesMicrosoft System Center 2012Service Manager.
Next you need to map a namespace to your XAML to use this assembly.
Finally, you need to add some code to tell Service Manager which controls need to be validated and what kind of validation needs to be done. There are a wide range of options here, so I'll show you a few examples.
You can see there are some differences with how you apply the validation rules depending on what type of control you are working with. Your best bet is to build yourself a test environment to play around and learn what works for you.
Next time - more on validation (including validation templates, which you can see I am using) and some other WPF tricks I've picked up along the way!