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.
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);
}
}
// ...
}
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"
},
// ...
};
}
}
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.
- MainWindow.xaml (VB: MainWindow.xaml)
- MainWindow.xaml.cs (VB: MainWindow.xaml.vb)
- Data.cs (VB: Data.vb)
- WPF Data Grid – Bind to Dynamic Data
- WPF Data Grid – Handle Drag and Drop Operations
- WPF Data Grid – Specify Custom Content for Column Chooser Headers
(you will be redirected to DevExpress.com to submit your response)