locked
How to set compartment's default expanded property to false? RRS feed

  • Question

  • The compartmet's are expanded by default when the shape is added to the diagram? How can I set the default behaviour to collapsed?

    Thanks.
    Thursday, November 10, 2005 5:36 AM

Answers

  • You can collapse just the compartments within a Compartment shape on its creation with the following code customization:



    namespace CompanyName.ProjectName.Language27.Designer
    {
     #region Using directives

     using System;
     using System.Collections.Generic;
     using Microsoft.VisualStudio.Modeling;
     using System.Diagnostics;
     using Microsoft.VisualStudio.Modeling.Utilities;
     using System.Drawing;
     using Microsoft.VisualStudio.Modeling.Diagrams;

     #endregion

     public partial class ClassShape
     {   
      public override void EnsureCompartments()
      {
       base.EnsureCompartments();

       foreach (Compartment comp in this.NestedChildShapes)
       {
        comp.IsExpanded = false;
       }
      }
     }
    }

     



    Update: I've put this on my blog as an entry, because other folks may find it useful. And, I explain it a little more too.

    Saturday, November 12, 2005 12:37 AM

All replies

  • Thursday, November 10, 2005 9:43 AM
  • Hi,
    The workaround says FindCompartment returns NULL when called from OnInitialize().

    I want my shape to be expanded but the compartments to be collapsed by default.

    Is it possible?

    Thursday, November 10, 2005 7:50 PM
  • You can collapse just the compartments within a Compartment shape on its creation with the following code customization:



    namespace CompanyName.ProjectName.Language27.Designer
    {
     #region Using directives

     using System;
     using System.Collections.Generic;
     using Microsoft.VisualStudio.Modeling;
     using System.Diagnostics;
     using Microsoft.VisualStudio.Modeling.Utilities;
     using System.Drawing;
     using Microsoft.VisualStudio.Modeling.Diagrams;

     #endregion

     public partial class ClassShape
     {   
      public override void EnsureCompartments()
      {
       base.EnsureCompartments();

       foreach (Compartment comp in this.NestedChildShapes)
       {
        comp.IsExpanded = false;
       }
      }
     }
    }

     



    Update: I've put this on my blog as an entry, because other folks may find it useful. And, I explain it a little more too.

    Saturday, November 12, 2005 12:37 AM