CallbackValidationRole for checkbox control
The example below shows how to create a new CallbackValidationRole and register it for checkbox usercontrol. It is done in the Loaded event called once when the form is firstly loaded in the browser.
using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; using System.Xml.Linq; using Neurodot.Forms.Controls; using Neurodot.Forms.CustomControls.RadioGroup; using Neurodot.Forms.Render; using Neurodot.Forms.Render.Interfaces; public static partial class FormCodeClass { // To find controls in the current visual tree (i.e. the form) use static methods: // object ThisForm.FindElement(string elementName); or // T ThisForm.FindElement<T>(string elementName); static CheckBox _checkBox = ThisForm.FindElement<CheckBox>("CheckBoxConfirm"); public static void Loaded(object sender, System.Windows.RoutedEventArgs e) { var role = new CallbackValidationRole("$CheckValidationMessage") { Callback = ValidateConfirmCheckBox }; ThisForm.RegisterValidationRole(_checkBox, role); } // Validates if the checkbox is checked. // Returns true if the checkbox is checked (valid); otherwise, false (invalid). private static bool ValidateConfirmCheckBox() { return (_checkBox.IsChecked == true); } }