Overview of SwEx.PMPage framework for SOLIDWORKS API

Edit ArticleEdit Article

Property Manager Page driven by data model
Property Manager Page driven by data model

Data model

Start by defining the data model required to be filled by property manager page.

public class DataModelSimple
    public string Text { get; set; }
    public int Size { get; set; } = 48;
    public double Number { get; set; } = 10.5;

Use properties with public getters and setters

Events handler

Create handler for property manager page by inheriting the public class from PropertyManagerPageHandlerEx class.

This class will be instantiated by the framework and will allow handling the property manager specific events from the add-in.

public class MyPMPageHandler : PropertyManagerPageHandlerEx

Class must be com visible and have public parameterless constructor.

Ignoring members

If it is required to exclude the members in the data model from control generation such members should be decorated with IgnoreBindingAttribute

public class DataModelIgnore
    public string Text { get; set; }

    public int CalculatedField { get; set; } //control will not be generated for this field

Creating instance

Create instance of the property manager page by passing the type of the handler and data model instance into the generic arguments

Data model can contain predefined (default) values. Framework will automatically use this values in the corresponding controls.

private PropertyManagerPageEx<MyPMPageHandler, DataModel> m_Page;
private DataModel m_Data = new DataModel();

private enum Commands_e

public override bool OnConnect()
    m_Page = new PropertyManagerPageEx<MyPMPageHandler, DataModel>(App);
    return true;

private void ShowPmpPage(Commands_e cmd)
    m_Page.Handler.Closed += OnPageClosed;

private void OnPageClosed(swPropertyManagerPageCloseReasons_e reason)
    Debug.Print($"Text: {m_Data.Simple.Text}");
    Debug.Print($"Size: {m_Data.Simple.Size}");
    Debug.Print($"Number: {m_Data.Simple.Number}");

Store instance of the data model and the property page in the class variables. This will allow to reuse the data model in the different page instances.


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial