# Property Attributes | WPF Controls | DevExpress Documentation

The **PropertyGrid** control recognizes [property attributes](/WPF/16863/mvvm-framework/data-annotation-attributes) specified in the model.

**Property attributes** allow you to configure the appearance and behavior of the **PropertyGrid** control on the model level. To use **property atributes** in your project, reference the **System.ComponentModel** namespace.

[View Example: Configure Properties at the Data Model Level](https://github.com/DevExpress-Examples/wpf-property-grid-apply-data-annotation-attributes)

The following example demonstrates the **property attribute** syntax.

- C#

<section id="tabpanel_Vnz1sZ6J2a_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<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;
...
[TypeConverter(typeof(ExpandableObjectConverter)), Description(&quot;Customer&#39;s address&quot;)]
public SimpleAddress Address { get; set; }
</code></pre></section>

The following table lists some of the property attributes recognized by the **PropertyGrid** control.

| Attribute | Description |
| --- | --- |
| BrowsableAttribute | Specifies whether the property is displayed within the property grid. |
| CategoryAttribute | Specifies the property’s [category](/WPF/117082/controls-and-libraries/property-grid/property-categories). |
| DefaultValueAttribute | Specifies the property’s default value. |
| DescriptionAttribute | Specifies the property’s [description](/WPF/15629/controls-and-libraries/property-grid/visual-elements/descriptions). |
| DisplayNameAttribute | Specifies the property’s display name. |
| ReadOnlyAttribute | Specifies whether the property is read-only. |
| TypeConverterAttribute | Specifies a type converter for the property.<br><br><br>To learn more, see [Expandability Customization](/WPF/117149/controls-and-libraries/property-grid/expandability-customization). |
| ConvertToAttribute | Specifies a type converter’s destination type. |
| InstanceInitializerAttribute | Specifies an instance initializer for the property.<br><br><br>To learn more, see [Collection Definitions](/WPF/15719/controls-and-libraries/property-grid/property-definitions/collection-definitions). |
| DisplayFormatAttribute | Specifies how to display and format the property’s value. |
| PropertyGridEditorAttribute | Specifies the property template. |

Refer to the following help topic for a complete list of supported attributes: [Data Annotation Attributes](/WPF/16863/mvvm-framework/data-annotation-attributes).

## Apply Annotation Attributes

The following example demonstrates the use of various **property attributes**.

- C#

<section id="tabpanel_Vnz1sZ6J2a-1_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-code-links="{&quot;/ (System.Collections.Generic)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.collections.generic&quot;,&quot;/ (System.ComponentModel)(?:;|$)/&quot;:&quot;https://learn.microsoft.com/dotnet/api/system.componentmodel&quot;}" class="lang-csharp">using System.Collections.Generic;
using System.ComponentModel;
...
public class Customer {
    [Browsable(false), ReadOnly(true)]
    public int ID { get; set; }
    [Category(&quot;Customer Info&quot;), Description(&quot;Customer&#39;s full name&quot;)]
    public string Name { get; set; }
    [Category(&quot;Contact&quot;), Description(&quot;Customer&#39;s email address&quot;)]
    public string Email { get; set; }
    [Category(&quot;Contact&quot;), Description(&quot;Customer&#39;s phone number&quot;)]
    public string Phone { get; set; }
    [Category(&quot;Order Info&quot;), Description(&quot;Ordered items&quot;), DisplayName(&quot;Ordered Items&quot;)]
    public ProductList Products { get; set; }
}

public class Book {
    [DisplayName(&quot;ISBN&quot;)]
    public int ID { get; set; }
    public string Author { get; set; }
    public string Title { get; set; }
    public double Price { get; set; }
}

public class ProductList : List&lt;Object&gt; {
    public ProductList() : base() { }
    public override string ToString() {
        return &quot;Product List&quot;;
    }
}
</code></pre></section>

- C#

<section id="tabpanel_Vnz1sZ6J2a-2_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code class="lang-csharp">public class ViewModel {
    public Customer DemoCustomer { get; set; }
    public ViewModel() {
        DemoCustomer = new Customer()
        {
            ID = 0,
            Name = &quot;Anita Benson&quot;,
            Email = &quot;Anita_Benson@example.com&quot;,
            Phone = &quot;7138638137&quot;,
            Products = new ProductList {
                new Book
                {
                    ID = 47583,
                    Author = &quot;Arthur Cane&quot;,
                    Title = &quot;Digging deeper&quot;,
                    Price = 14.79
                }
            }
        };
    }
}
</code></pre></section>

- XAML

<section id="tabpanel_Vnz1sZ6J2a-3_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 SelectedObject=&quot;{Binding DemoCustomer}&quot;/&gt;
</code></pre></section>

![PG_Attributes](/WPF/images/pg_attributes124917.png)

## PropertyGridEditor Attribute

The `PropertyGridEditor` attribute allows you to apply a property template at the data model level.

![PropertyGridEditorAttribute](/WPF/images/PropertyGridEditorAttribute_Example.png)

You can specify a template for the entire property definition:

- XAML

<section id="tabpanel_Vnz1sZ6J2a-4_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;DataTemplate x:Key=&quot;PropertyTemplate&quot;&gt;
    &lt;dxprg:PropertyDefinition Header=&quot;Full Address&quot; HeaderShowMode=&quot;OnlyHeader&quot;/&gt;
&lt;/DataTemplate&gt;
&lt;DataTemplate x:Key=&quot;CollectionDefinitionTemplate&quot;&gt;
    &lt;dxprg:CollectionDefinition HeaderShowMode=&quot;OnlyHeader&quot; AllowRemoveItems=&quot;False&quot;/&gt;
&lt;/DataTemplate&gt;
</code></pre></section>

- C#

<section id="tabpanel_Vnz1sZ6J2a-5_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-highlight-lines="[[5],[7]]" class="lang-csharp">public class Department {
    [Display(Name = &quot;Department Name&quot;)]
    public string Name { get; set; }
    [TypeConverter(typeof(ExpandableObjectConverter))]
    [PropertyGridEditor(TemplateKey = &quot;PropertyTemplate&quot;)]
    public Location Location { get; set; }
    [PropertyGridEditor(TemplateKey = &quot;CollectionDefinitionTemplate&quot;)]
    public ObservableCollection&lt;Employee&gt; Employees { get; set; }
}
</code></pre></section>

You can also specify the editor’s template only:

- XAML

<section id="tabpanel_Vnz1sZ6J2a-6_tabid-xaml" role="tabpanel" data-tab="tabid-xaml">
<pre><code class="lang-xaml">&lt;DataTemplate x:Key=&quot;ButtonEditTemplate&quot;&gt;
    &lt;dxe:ButtonEdit Name=&quot;PART_Editor&quot;
                    IsTextEditable=&quot;False&quot;/&gt;
&lt;/DataTemplate&gt;
</code></pre></section>

- C#

<section id="tabpanel_Vnz1sZ6J2a-7_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-highlight-lines="[[1]]" class="lang-csharp">[PropertyGridEditor(TemplateKey = &quot;ButtonEditTemplate&quot;)]
public class Employee : BindableBase {
    public string FirstName { get { return GetValue&lt;string&gt;(); } set { SetValue(value); } }
    public string LastName { get { return GetValue&lt;string&gt;(); } set { SetValue(value); } }
    public DateTime BirthDate { get { return GetValue&lt;DateTime&gt;(); } set { SetValue(value); } }
    public bool Married { get { return GetValue&lt;bool&gt;(); } set { SetValue(value); } }

    public override string ToString() {
        return FirstName + &quot; &quot; + LastName;
    }
}
</code></pre></section>

[View Example: Use the PropertyGridEditor Attribute to Define a Property Editor](https://github.com/DevExpress-Examples/wpf-property-grid-use-data-annotations-to-define-property-editor)

See Also

[Property Categories](/WPF/117082/controls-and-libraries/property-grid/property-categories)