# Expandability Customization | WPF Controls | DevExpress Documentation

## Overview

The **PropertyGrid** control allows you to customize property expandability in the following ways.

- At the control level, using the **AllowExpanding** property.
- At the model level, using the [TypeConverter](https://learn.microsoft.com/dotnet/api/system.componentmodel.typeconverter) attribute.

## Customizing Property Expandability at the Control Level

The following **PropertyGrid** properties affect the expandability behavior.

- [PropertyGridControl.AllowExpanding](/WPF/DevExpress.Xpf.PropertyGrid.PropertyGridControl.AllowExpanding) specifies the expandability behavior for the entire property grid.
- [PropertyDefinition.AllowExpanding](/WPF/DevExpress.Xpf.PropertyGrid.PropertyDefinition.AllowExpanding) specifies the expandability behavior for individual properties.

Note

The [PropertyDefinition.AllowExpanding](/WPF/DevExpress.Xpf.PropertyGrid.PropertyDefinition.AllowExpanding) property has higher precedence than the [PropertyGridControl.AllowExpanding](/WPF/DevExpress.Xpf.PropertyGrid.PropertyGridControl.AllowExpanding) property.

The following table lists the available **AllowExpanding** property values and corresponding expandability modes.

| AllowExpanding<br><br>property value | Property grid expandability behavior |
| --- | --- |
| Default | Expands properties according to their type converters. |
| Force | Expands all properties. |
| ForceIfNoTypeConverter | Expands all properties that don’t have a type converter. |
| Never | Properties are not expandable. |

The following example demonstrates the **AllowExpanding** property precedence.

- XAML
- C#
- C#

<section id="tabpanel_csQYY0xAKp_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;Window.DataContext&gt;
    &lt;local:ViewModel/&gt;
&lt;/Window.DataContext&gt;
...
&lt;dxprg:PropertyGridControl Grid.Column=&quot;1&quot; SelectedObject=&quot;{Binding Data}&quot; ShowProperties=&quot;All&quot; AllowExpanding=&quot;Force&quot;&gt;
    &lt;dxprg:PropertyDefinition Path=&quot;PublicInfo&quot;/&gt;
    &lt;dxprg:CollectionDefinition Path=&quot;PrivateInfo&quot; AllowExpanding=&quot;Never&quot;/&gt;
&lt;/dxprg:PropertyGridControl&gt;
</code></pre></section>
<section id="tabpanel_csQYY0xAKp_tabid-csharp" role="tabpanel" data-tab="tabid-csharp" aria-hidden="true" hidden="hidden">
<pre><code class="lang-csharp">public class ViewModel {
    public Container Data { get; set; }
    public ViewModel() {
        Data = new Container
        {
            PublicInfo = new ClassWithProperties() { Id=0, Name = &quot;Expandable&quot;},
            PrivateInfo = new List&lt;ClassWithProperties&gt;
            {
                new ClassWithProperties() { Id=1, Name=&quot;Not expandable&quot; },
                new ClassWithProperties() { Id=2, Name=&quot;Not expandable&quot; }
            }
        };
    }
}
</code></pre></section>
<section id="tabpanel_csQYY0xAKp_tabid-csharp-1" role="tabpanel" data-tab="tabid-csharp-1" aria-hidden="true" hidden="hidden">
<pre><code class="lang-csharp">public class ClassWithProperties {
    public int Id { get; set; }
    public string Name { get; set; }
    public override string ToString() {
        return Name;
    }
}

public class Container {
    public ClassWithProperties PublicInfo { get; set; }
    public List&lt;ClassWithProperties&gt; PrivateInfo { get; set; }
}
</code></pre></section>

![PG_expandability_0](/WPF/images/pg_expandability_0124883.png)

## Customizing Property Expandability at the Model Level

To control property expandability from the model, use the [TypeConverter](https://learn.microsoft.com/dotnet/api/system.componentmodel.typeconverter) attribute.

Important

A **type converter** affects the expandability if the **AllowExpanding** property is set to **Default** or **ForceIfNoTypeConverter**.

Note

To learn more about the **property attributes** supported by the **PropertyGrid** control, see [Property Attributes](/WPF/15623/controls-and-libraries/property-grid/property-attributes).

- XAML
- C#
- C#

<section id="tabpanel_csQYY0xAKp-1_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;Window.DataContext&gt;
    &lt;local:ViewModel/&gt;
&lt;/Window.DataContext&gt;
...
&lt;dxprg:PropertyGridControl Grid.Column=&quot;1&quot; SelectedObject=&quot;{Binding Data}&quot; ShowProperties=&quot;All&quot; AllowExpanding=&quot;Default&quot;&gt;

    &lt;!--No type converter, not expandable--&gt;
    &lt;dxprg:PropertyDefinition Path=&quot;Simple&quot;/&gt;

    &lt;dxprg:PropertyDefinition Path=&quot;Expandable&quot;/&gt;

    &lt;dxprg:PropertyDefinition Path=&quot;NotExpandable&quot;/&gt;

    &lt;!--No type converter, expandable--&gt;
    &lt;dxprg:CollectionDefinition Path=&quot;Collection&quot;/&gt;

&lt;/dxprg:PropertyGridControl&gt;
</code></pre></section>
<section id="tabpanel_csQYY0xAKp-1_tabid-csharp" role="tabpanel" data-tab="tabid-csharp" aria-hidden="true" hidden="hidden">
<pre><code data-code-links="{&quot;/ (System.ComponentModel)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.componentmodel&quot;}" class="lang-csharp">using System.ComponentModel;
...
public class ClassWithProperties {
    public int Id { get; set; }
    public string Name { get; set; }
    public override string ToString() {
        return Name;
    }
}

public class Container {
    public ClassWithProperties Simple { get; set; }
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public ClassWithProperties Expandable { get; set; }
    [TypeConverter(typeof(NotExpandableConverter))]
    public ClassWithProperties NotExpandable { get; set; }
    public List&lt;ClassWithProperties&gt; Collection { get; set; }
}

public class NotExpandableConverter : TypeConverter {
    public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
        return false;
    }
}
</code></pre></section>
<section id="tabpanel_csQYY0xAKp-1_tabid-csharp-1" role="tabpanel" data-tab="tabid-csharp-1" aria-hidden="true" hidden="hidden">
<pre><code class="lang-csharp">public class ViewModel {
    public Container Data { get; set; }
    public ViewModel() {
        Data = new Container
        {
            Simple = new ClassWithProperties() { Id=0, Name = &quot;Simple&quot;},
            Expandable = new ClassWithProperties() { Id=1, Name = &quot;Expandable&quot;},
            NotExpandable = new ClassWithProperties() { Id = 2, Name= &quot;Not expandable&quot; },
            Collection = new List&lt;ClassWithProperties&gt;
            {
                new ClassWithProperties() { Id=3, Name=&quot;Item1&quot; },
                new ClassWithProperties() { Id=4, Name=&quot;Item2&quot; }
            }
        };
    }
}
</code></pre></section>

![PG_expandability_1](/WPF/images/pg_expandability_1124881.png)

See Also

[Property Definitions](/WPF/15521/controls-and-libraries/property-grid/property-definitions)

[Collection Definitions](/WPF/15719/controls-and-libraries/property-grid/property-definitions/collection-definitions)

[Property Attributes](/WPF/15623/controls-and-libraries/property-grid/property-attributes)