Skip to content

DevExpress-Examples/wpf-property-grid-display-object-properties

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF Property Grid - Inspect and Edit Object Properties

This example uses the WPF PropertyGridControl to inspect and modify properties of data objects displayed in the GridControl. Use the PropertyGridControl to create object inspectors inspired by the Properties window in the Visual Studio IDE.

Display Object Properties

Implementation Details

Source Object

The Contact class declares public bindable properties. The PropertyGridControl inspects the object's public properties and allows users to browse and modify them. The Contact class implements property change notifications. Updates made in the PropertyGridControl are applied immediately to the source object and reflected in the GridControl.

public class Contact : BindableBase {
    string _FirstName;
    public string FirstName {
        get { return _FirstName; }
        set {
            _FirstName = value;
            RaisePropertyChanged(() => FirstName);
        }
    }
    // ...
}

Data Source

The ViewModel exposes a typed collection of contacts.

public class ViewModel {
    public List<Contact> Items { get; set; }
    public ViewModel() {
        Items = new List<Contact> {
            new Contact() {
                FirstName = "Carolyn",
                LastName = "Baker",
                Email = "[email protected]", 
                Phone = "(555)349-3010",
                Address = "1198 Theresa Cir", 
                City = "Whitinsville", 
                State = "MA", 
                Zip = "01582"
            }, 
            // ...
        };
    }
}

Property Grid Configuration

This example creates two Property Grid controls and displays them in tab containers. The first Property Grid control inspects the Contact object that corresponds to the focused item in the GridControl. The second Property Grid control inspects Contact objects that correspond to selected items in the GridControl:

<dx:DXTabControl>
    <dx:DXTabItem Header="Edit properties of the focused row">
        <dxprg:PropertyGridControl SelectedObject="{Binding Path=CurrentItem, ElementName=grid}" ShowCategories="False"/>
    </dx:DXTabItem>
    <dx:DXTabItem Header="Edit properties of selected rows">
        <dxprg:PropertyGridControl SelectedObjects="{Binding Path=SelectedItems, ElementName=grid}" ShowCategories="False"/>
    </dx:DXTabItem>    
    
    ...

</dx:DXTabControl>

When a user selects a contact, the PropertyGridControl displays its properties. The user can edit each property value directly in the grid.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Uses the WPF Property Grid Control to display object properties.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5