Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I add a nested design-time property to a user control?
    text
    copied!<p>I have a user control that contains a number of panel controls. The user control has logic to set the visibility of each panel, based on the values of some variables contained in the user control.</p> <p>I would like to enhance this functionality by adding the following enumeration:</p> <pre><code>public enum Visibility { Default, Always, Never } </code></pre> <p>where <code>Default</code> would use the current logic to set the panel's visibility, but <code>Always</code> would (obviously) make the panel always visible, and <code>Never</code> would always hide the panel.</p> <p>I would also like to add a "nested" design-time property named something like <code>PanelVisiblity</code> that the developer could expand, and see the panel names listed below, and allow them to assign a value from the <code>Visibility</code> enumeration for each.</p> <p>If I add properties like this:</p> <pre><code>public partial class MyControl : UserControl { public Visibility ActivePanel { get; set; } public Visibility CodePanel { get; set; } } </code></pre> <p>the <code>ActivePanel</code> and <code>CodePanel</code> properties appear in the Properties window in Visual Studio, and I can set them to one of the three values in the enum. However, when I refactored my code to try to create a nested property like this:</p> <pre><code>public partial class MyControl : UserControl { public class PanelVisibility { public enum Visibility { Default, Always, Never } public Visibility ActivePanel { get; set; } public Visibility CodePanel { get; set; } } } </code></pre> <p>I do not get an expandable <code>PanelVisiblity</code> property, I get a disabled <code>Visiblity</code> property, where the value is the namespace of class, plus 'PanelVisibility'.</p> <p>I have Googled a number of variations in phrasing this search, but have not been able to find anything like what I'm looking for.</p> <p>Any direction would be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload