Back to Devexpress

CellEditorPresenter Class

wpf-devexpress-dot-xpf-dot-propertygrid-db1c5283.md

latest5.8 KB
Original Source

CellEditorPresenter Class

Represents an object that is used to configure and display cell editors within property grid cells.

Namespace : DevExpress.Xpf.PropertyGrid

Assembly : DevExpress.Xpf.PropertyGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PropertyGrid

Declaration

csharp
public class CellEditorPresenter :
    Panel,
    INavigationSupport
vb
Public Class CellEditorPresenter
    Inherits Panel
    Implements INavigationSupport

Example

This example demonstrates a custom template that displays multiple properties in a single PropertyGridControl cell.

Both the absolute and relative paths are specified for the cell editor presenter objects.

csharp
using System;

namespace DXSample {
    public class CategoryAttributesViewModel {
        public virtual Person Person { get; protected set; }
        public CategoryAttributesViewModel() {
            Person = new Person {
                FirstName = "Anita",
                LastName = "Benson",
                Address = new Address {
                    AddressLine1 = "9602 South Main",
                    AddressLine2 = "Seattle, 77025, USA",
                },
                Phone = "7138638137",
            };
        }
    }
    public class Person {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public Address Address { get; set; }
        public string Phone { get; set; }
    }
    public class Address {
        public string AddressLine1 { get; set; }
        public string AddressLine2 { get; set; }
    }
}
xaml
<Window x:Class="DXSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxprg="http://schemas.devexpress.com/winfx/2008/xaml/propertygrid"  
        xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
        xmlns:local="clr-namespace:DXSample"
        DataContext="{dxmvvm:ViewModelSource Type=local:CategoryAttributesViewModel}"
        dx:ThemeManager.ThemeName="Office2013"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxprg:PropertyGridControl SelectedObject="{Binding Person}" ExpandCategoriesWhenSelectedObjectChanged="True" ShowProperties="WithPropertyDefinitions">
            <dxprg:PropertyGridControl.PropertyDefinitions>
                <dxprg:PropertyDefinition Path="FirstName"/>
                <dxprg:PropertyDefinition Path="LastName"/>
                <dxprg:PropertyDefinition Path="Address" Header="Contact">
                    <dxprg:PropertyDefinition.ContentTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <dxprg:CellEditorPresenter Path="AddressLine1"/>
                                <dxprg:CellEditorPresenter Path="AddressLine2"/>
                                <dxprg:CellEditorPresenter Path="Phone" PathMode="Absolute"/>
                            </StackPanel>
                        </DataTemplate>
                    </dxprg:PropertyDefinition.ContentTemplate>
                </dxprg:PropertyDefinition>
            </dxprg:PropertyGridControl.PropertyDefinitions>
        </dxprg:PropertyGridControl>
    </Grid>
</Window>
vb
Imports System

Namespace DXSample
    Public Class CategoryAttributesViewModel
        Private privatePerson As Person
        Public Overridable Property Person() As Person
            Get
                Return privatePerson
            End Get
            Protected Set(ByVal value As Person)
                privatePerson = value
            End Set
        End Property
        Public Sub New()
            Person = New Person With {.FirstName = "Anita", .LastName = "Benson", .Address = New Address With {.AddressLine1 = "9602 South Main", .AddressLine2 = "Seattle, 77025, USA"}, .Phone = "7138638137"}
        End Sub
    End Class
    Public Class Person
        Public Property FirstName() As String
        Public Property LastName() As String
        Public Property Address() As Address
        Public Property Phone() As String
    End Class
    Public Class Address
        Public Property AddressLine1() As String
        Public Property AddressLine2() As String
    End Class
End Namespace

Inheritance

Object DispatcherObject DependencyObject Visual UIElement FrameworkElement Panel CellEditorPresenter

See Also

CellEditorPresenter Members

DevExpress.Xpf.PropertyGrid Namespace