Question

I am implementing a custom language service for Visual Studio; the project node shall provide some configuration independent property pages (like Application-, Debug-, Build Events, ...) which are displayed in a tabbed view. The registration of property pages works somehow, but they show up in a non-modal dialog, which is not the wanted behavior...

This is what I´ve done...

I´ve a created the PropertyPageBase class that implements the IPropertyPage interface (I can provide further details of that implementation, if necessary)...

[ComVisible(true)]
public abstract class PropertyPageBase : IPropertyPage
{
    private Control control;

    protected abstract Control CreateControl();

    public Control Control
    {
        get { return this.control ?? (this.control = this.CreateControl()); }
    }

    ...
} 

Custom property pages are derived from that base class; for instance...

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid(...)]
public sealed class GeneralPropertyPage : PropertyPageBase
{
    protected override Control CreateControl()
    {
        return new GeneralPropertyPageControl(this);
    }
}

I use MPF (Managed Package Framework for Projects) to implement node types for the project hierarchy. So, there´s the ProjectNodeBase class (which is derived from MPF ProjectNode) where I´ve overriden the GetConfigurationIndependentPropertyPages method; this implementation obtains property pages from attached attributes; so I don´t have to override that method again in my concrete implementation...

public abstract class ProjectNodeBase : ProjectNode
{
    protected override Guid[] GetConfigurationIndependentPropertyPages()
    {
        Type thisType = this.GetType();

        IEnumerable<Type> pageTypes = thisType.GetCustomAttributes(typeof(ProvideProjectPropertyPageAttribute), true)
            .Cast<ProvideProjectPropertyPageAttribute>()
            .Select(x => x.PropertyPageType);

        return pageTypes.Select(x => x.GUID)
            .ToArray();
    }
}

At my concrete project node class, I just declare project property pages like that...

[ProvideProjectPropertyPageAttribute(PropertyPageType = typeof(GeneralPropertyPage))]
public sealed class CustomProjectNode : ProjectNodeBase 
{
    ...
}

As I wrote, the property page gets shown when I click the Properties-command within the project´s context menu (in Solution Explorer), but instead of the tabbed view a non-modal dialog appears. So, the question is, how I can tweak it to the wanted behavior?

Was it helpful?

Solution

The IPropertyPage implementation shown in the question just works fine...

The reason why the page was not shown in the tabbed property pages frame, was related to the CustomProjectNode class (which represents project nodes of my custom project system). I use a modified version of the Managed Package Framework for Projects for my project system hierarchy; so CustomProjectNode is derived from MPF´s ProjectNode class. This class provides the SupportsProjectDesigner property, which must be set to true.

[ProvideProjectPropertyPageAttribute(PropertyPageType = typeof(GeneralPropertyPage))]
public sealed class CustomProjectNode : ProjectNodeBase 
{
    public CustomProjectNode() : base()
    {
        this.SupportsProjectDesigner = true;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top