Question

I have a Visual Studio Extensions project with VSPackage extending Microsoft.VisualStudio.Shell.Package.

There is this class:

public class PropertyPageItem
    {
        private string _item1;
        private string _item2;

        public PropertyPageItem()
        {
            _item1 = "ITEM1";
            _item2 = "ITEM2";
        }

        [Description("Item1")]
        [Category("Item-Field")]
        public string Item1
        {
            get
            {
                return _item1;
            }
            set
            {
                _item1 = value;
            }
        }

        [Description("Item2")]
        [Category("Item-Field")]
        public string Item2
        {
            get
            {
                return _item2;
            }
            set
            {
                _item2 = value;
            }
        }
    }

The Class above is not dynamic (doesn't consider events etc), it's for the sake of understanding the method.

How can we link/expose this class to the Visual Studio Property Window? It's the same window where we can see file properties while browsing through the Solution Explorer. The objective is to use this window and not create another Property Grid Control.

Tried following instructions on this link but it confused me further.

Was it helpful?

Solution

After a small research I figured out how to do it.

Follow the instructions in link

In Step 6 of that walkthrough, replace 'this' with 'new PropertyPageItem()'

public override void OnToolWindowCreated()
{
    ArrayList listObjects = new ArrayList();
    listObjects.Add(new PropertyPageItem());
    SelectList(listObjects);
}

Following until step 7 on the "Exposing Properties to the Properties Window" section, the objective is achieved and properties in PropertyPageItem class are exposed onto the Visual Studio PropertyWindow.

Hope this is helpful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top