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 DataModel
{
    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.

[ComVisible(true)]
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 DataModel
{
    public string Text { get; set; }

    [IgnoreBinding]
    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_MyPage;
private DataModel m_Data = new DataModel();
...
m_Page = new PropertyManagerPageEx<MyPMPageHandler, DataModel>(m_Data, m_App);
m_Page.Show();

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.