Devi
Devi

Reputation: 336

How can i add nested Properties in Property Grid

How can i add nested Properties in the WPF Property Grid.

I want to add List of Font properties Under Font which is the child of Style. How can i get the list of font attributes by the nested properties?

Style
  Font
    Font Family
    Font Size
    Font Style ... and so on..

 internal class Properties()
 {
  public Properties()
    {
        this.FontPropertiesCollection = new List<FontProperties>()
        {
            ????
         }
     }
    [CategoryAttribute("Font")]
    [DisplayName("Font")]
    public List<FontProperties> FontPropertiesCollection
    { 
        get; 
        set; 
    }
 }


internal class FontProperties
{
    [CategoryAttribute("Font")]
    [DisplayNameAttribute("Font Family")]
    public string FontFamily
    {
        get
        {
            return this.fontFamily;
        }
        set
        {
            if (value != this.fontFamily)
            {
                this.fontFamily= value;
                this.OnPropertyChanged("FontFamily");
            }
        }
    }

       ..... and so on    

Upvotes: 0

Views: 917

Answers (1)

Emond
Emond

Reputation: 50692

Using the Category attribute you only get one level of nesting.

The only way that I can see to create what you want is by implementing a UI Type Editor

You will need to build all of the UI.

In general I would advise against this because this is not what the user will expect and it will mess with the user's mind when he sorts the properties alphabetically.

Upvotes: 1

Related Questions