locked
Communication between two Property Pages? RRS feed

  • Question

  • I created a custom project package by using the MPF. The custom project has 2 property pages, say A and B.

    How to update properties in B automatically when user changes a property in A?

    Thanks alot.

    lcasperr

    Wednesday, March 28, 2012 6:52 PM

Answers

  • I just register each property page in the related project node, so property pages may access each other through the project node object.

    The code is as follows.

    class MyPropertyPage : SettingsPage
    {
    ...
        protected override void BindProperties()
        {
            MyProjectNode node = this.ProjectMgr as MyProjectNode;
            node.PropertyPage1 = this;
            ...
        }
    }
    • Marked as answer by lucy-liu Tuesday, April 10, 2012 6:56 AM
    Sunday, April 8, 2012 2:06 AM

All replies

  • quote from this link http://social.msdn.microsoft.com/Forums/en-US/vcmfcatl/thread/38b4cb21-6607-4bae-9b0b-24de2a296ce0                

    Put the data you need to share in the class that is the parent of the pages (usually a property sheet), that way both pages can access it by using GetParent or having a reference to the data in the parent's
    instance.

    Please also look at Communication between Property Sheet & its Pages 


    http://social.msdn.microsoft.com/forums/en-us/vcgeneral/thread/15ED9E1A-4A3A-4302-AA9B-84C8054BB7EE


    Monday, April 2, 2012 7:03 AM
  • Hi breathfish,

    Thanks for the update. However my property page is derived from Microsoft.VisualStudio.Project.SettingsPage of MPF, and there is no "GetParent" method in the page object.

    I have found an "ungly" approach to solve this problem.

    Thanks anyway.

    lcasperr

    Thursday, April 5, 2012 1:50 PM
  • Hi lcasperr, could you share your workaround in this thread. i will very appreciate it.
    Friday, April 6, 2012 9:07 AM
  • I just register each property page in the related project node, so property pages may access each other through the project node object.

    The code is as follows.

    class MyPropertyPage : SettingsPage
    {
    ...
        protected override void BindProperties()
        {
            MyProjectNode node = this.ProjectMgr as MyProjectNode;
            node.PropertyPage1 = this;
            ...
        }
    }
    • Marked as answer by lucy-liu Tuesday, April 10, 2012 6:56 AM
    Sunday, April 8, 2012 2:06 AM