Framework will automatically generate the best suitable control for the public property in the data model. For example for all numeric properties the number box control will be generated. For all string properties text box control will be generated. For all complex types group box will be generated.

The style of the controls can be customized via attributes.

Accessing controls

Access to controls is provided via IPropertyManagerPageControlEx wrapper interface. Common properties can be accessed via this interface (such as control id, enable or visible flags). Underlying native SOLIDWORKS control can be accessed via IPropertyManagerPageControlEx::SwControl property. It returns the pointer to corresponding IPropertyManagerPageControl which can be cast to specific control such as IPropertyManagerPageSelectionbox, IPropertyManagerPageCombobox, IPropertyManagerPageTextbox etc.

All controls can be accessed via IPropertyManagerPageEx::Controls property.

Dependencies and tags

Control tags allow to track the controls created from the data model properties. Tags can be assigned via ControlTagAttribute decorated on data model properties. Control tag can be represented as any type, it is recommended to use enumerations or strings as tags

public enum ControlTags_e //control tags are defined as enumeration
{
    EnableCheckBox,
    InputTextBox
}

public class PageViewModel
{
    [ControlTag(ControlTags_e.EnableCheckBox)] //tag assigned to boolean property to track corresponding CheckBox control
    public bool Enable { get; set; }

    [ControlTag(ControlTags_e.InputTextBox)] //tag assigned to text property to track corresponding TextBox control
    [DependentOn(typeof(InputBoxEnableHandler), ControlTags_e.EnableCheckBox)] //defining the dependency of the text box to check box. Dependency is handled via InputBoxEnableHandler
    public string Input { get; set; }
}

public class InputBoxEnableHandler : DependencyHandler
{
    protected override void UpdateControlState(IPropertyManagerPageControlEx control, IPropertyManagerPageControlEx[] parents)
    {
        var enable = (bool)parents.First().GetValue(); //value of the parent control (i.e. check flag of check box control)
        control.Enabled = enable; //setting the enable of text box control based on the check box value
    }
}

Handler class must inherit DependencyHandler class and UpdateControlState method will be called every time when state needs to be resolved (i.e. the value of the parent control is changed).