menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PropertyGridItem - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PropertyGridItem

    Represents the class that encapsulates the layout, group and editor setting for a property fields appearing in PropertyGrid.

    Inheritance
    System.Object
    PropertyGridItem
    Implements
    System.ComponentModel.INotifyPropertyChanged
    Namespace: Syncfusion.Windows.PropertyGrid
    Assembly: Syncfusion.PropertyGrid.Wpf.dll
    Syntax
    public class PropertyGridItem : DependencyObject, INotifyPropertyChanged

    Constructors

    PropertyGridItem()

    Initializes a new instance of the PropertyGridItem class.

    Declaration
    public PropertyGridItem()

    Fields

    DescriptionTemplateProperty

    Using a DependencyProperty as the backing store for DescriptionTemplate. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty DescriptionTemplateProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    ItemsProperty

    Using a DependencyProperty as the backing store for Items. This enables animation, styling, binding, etc...

    Declaration
    public static readonly DependencyProperty ItemsProperty
    Field Value
    Type
    System.Windows.DependencyProperty

    Properties

    CategoryName

    Gets or sets the category name of data field that is used to group properties in view.

    Declaration
    public string CategoryName { get; set; }
    Property Value
    Type Description
    System.String

    The default value is Misc.

    Description

    Gets or sets the description of the PropertyGridItem.

    Declaration
    public string Description { get; set; }
    Property Value
    Type Description
    System.String

    The default value is String.Empty.

    Remarks

    This information will be shown in description panel and tooltip of a property.

    DescriptionTemplate

    Gets or sets the template used to display the description of SelectedItem.

    Declaration
    public DataTemplate DescriptionTemplate { get; set; }
    Property Value
    Type
    System.Windows.DataTemplate
    Remarks

    DataContext of DescriptionTemplate is PropertyItem. PropertyItem has Name, Description and other useful properties, that can be bounded to the DescriptionTemplate. DescriptionTemplate can be defined in Autogenerating event, PropertyGridItem and PropertyGrid. AutoGeneratingPropertyGridItemEventArgs.DescriptionTemplate takes the highest precedence, PropertyGridItem.DescriptionTemplate takes second precedence, and PropertyGrid.DescriptionTemplate takes the last precedence.

    Examples

    The following example shows how to define a DescriptionTemplate of PropertyGridItem in XAML.

    <Window x:Class="PropertyGridConfigurationDemo.MainWindow" Icon="App.ico"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:PropertyGridConfigurationDemo" 
    WindowStartupLocation="CenterScreen"
    Title="Getting Started"  Height="550" Width="750" 
    xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PropertyGrid;assembly=Syncfusion.PropertyGrid.Wpf">
    <Window.DataContext>
    <local:ViewModel/>
    </Window.DataContext>
     <Grid>
      <syncfusion:PropertyGrid x:Name="pgrid" 
                               DescriptionPanelVisibility="Visible"
                               SelectedObject="{Binding EmployeeDetails}" 
                               AutoGenerateItems="false">
        <syncfusion:PropertyGrid.Items>
            <syncfusion:PropertyGridItem PropertyName = "Age" >
              <syncfusion:PropertyGridItem.DescriptionTemplate> 
                 <DataTemplate>  
                   <StackPanel>   
                      <TextBlock Text="{Binding Name}"/>
                      <TextBlock Text="{Binding Description}"/>
                   </StackPanel>
                 </DataTemplate>
              </syncfusion:PropertyGridItem.DescriptionTemplate>
            </syncfusion:PropertyGridItem>
            <syncfusion:PropertyGridItem PropertyName = "FavoriteColor" NestedPropertyDisplayMode="None"/>
        </syncfusion:PropertyGrid.Items>
      </syncfusion:PropertyGrid>
     </Grid>
    </Window>

    DisplayName

    Gets or sets the display name of the property field.

    Declaration
    public string DisplayName { get; set; }
    Property Value
    Type
    System.String
    Remarks

    By default, name of the property is displayed in property gird. DisplayName is used to display a more appropriate name. For example, if property name is ‘FullName’ and it should be displayed as ‘Full Name’.

    Editor

    Gets or sets the editor type based on the PropertyGrid property item data type.

    Declaration
    public ITypeEditor Editor { get; set; }
    Property Value
    Type Description
    ITypeEditor

    The default value is null.

    Remarks

    If Editor is not defined, PropertyGrid will automatically assign an editor based on PropertyType.

    IsReadOnly

    Gets or sets the value that indicates whether to allow user to edit the property value or not.

    Declaration
    public bool? IsReadOnly { get; set; }
    Property Value
    Type Description
    System.Nullable<System.Boolean>

    The default value is null.

    Remarks

    If PropertyItem only has get accessor, we don't modify the read only value.

    Items

    Gets or sets the nested PropertyGridItem collection.

    Declaration
    public ObservableCollection<PropertyGridItem> Items { get; set; }
    Property Value
    Type
    System.Collections.ObjectModel.ObservableCollection<PropertyGridItem>
    Remarks

    Populates only the nested properties which was defined in Items collection of PropertyGridItem.

    Examples

    The following example shows how to set the Items collection of PropertyGrid in XAML.

    <Window x:Class="PropertyGridConfigurationDemo.MainWindow" Icon="App.ico"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:PropertyGridConfigurationDemo" 
    WindowStartupLocation="CenterScreen"
    Title="Getting Started"  Height="550" Width="750" 
    xmlns:syncfusion="clr-namespace:Syncfusion.Windows.PropertyGrid;assembly=Syncfusion.PropertyGrid.Wpf">
    <Window.DataContext>
    <local:ViewModel/>
    </Window.DataContext>
     <Grid>
      <syncfusion:PropertyGrid x:Name="pgrid" SelectedObject="{Binding EmployeeDetails}" AutoGenerateItems="false">
        <syncfusion:PropertyGrid.Items>
            <syncfusion:PropertyGridItem PropertyName = "FirstName" DisplayName="Name"/>
            <syncfusion:PropertyGridItem PropertyName = "Age" >
                <syncfusion:PropertyGridItem.Editor>
                   <local:IntegerTextBoxEditor/>
                </syncfusion:PropertyGridItem.Editor>
            </syncfusion:PropertyGridItem>
            <syncfusion:PropertyGridItem PropertyName = "DOB" DisplayName="Birth Date" Description="Birth date of the actual person.">
               <syncfusion:PropertyGridItem.Items>
                   <syncfusion:PropertyGridItem PropertyName = "Day" />
                   <syncfusion:PropertyGridItem PropertyName = "Month" />
                    <syncfusion:PropertyGridItem PropertyName = "Year" />
               </syncfusion:PropertyGridItem.Items>
            </syncfusion:PropertyGridItem>
            <syncfusion:PropertyGridItem PropertyName = "FavoriteColor" NestedPropertyDisplayMode="None"/>
        </syncfusion:PropertyGrid.Items>
      </syncfusion:PropertyGrid>
     </Grid>
    </Window>

    NestedPropertyDisplayMode

    Gets or sets whether to populate nested properties of PropertyGridItem or not.

    Declaration
    public NestedPropertyDisplayMode? NestedPropertyDisplayMode { get; set; }
    Property Value
    Type
    System.Nullable<NestedPropertyDisplayMode>
    Remarks

    When None is set, nested properties of PropertyGridItem will not be populated. When Show is set, nested properties of PropertyGridItem will be populated. If NestedPropertyDisplayMode is not set, expand mode will be updated based on PropertyGridAttribute if we defined for respective property item. Otherwise the property expand mode will be updated based on PropertyGrid expand mode.

    PropertyName

    Gets or sets the name of the property.

    Declaration
    public string PropertyName { get; set; }
    Property Value
    Type Description
    System.String

    The default value is String.Empty.

    Remarks

    It is mandatory to set the PropertyName value. If PropertyName property is null or empty, InvalidOperationException will be thrown.

    PropertyType

    Gets or sets a data type of thePropertyGridItem.

    Declaration
    public Type PropertyType { get; set; }
    Property Value
    Type Description
    System.Type

    The default value is null.

    Remarks

    If a value is not set, PropertyGrid will automatically detect based on property type of PropertyName.

    Visibility

    Gets or sets a value indicating whether to show the data field for editing in PropertyGrid.

    Declaration
    public Visibility Visibility { get; set; }
    Property Value
    Type Description
    System.Windows.Visibility

    The default value is Visibility.Visible.

    Events

    PropertyChanged

    Occurs when a property value changes.

    Declaration
    public event PropertyChangedEventHandler PropertyChanged
    Event Type
    Type
    System.ComponentModel.PropertyChangedEventHandler

    Implements

    System.ComponentModel.INotifyPropertyChanged
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved