Skip to main content
A newer version of this page is available. .

CollectionDefinition.NewItemInitializer Property

Gets or sets a new item initializer. This is a dependency property.

Namespace: DevExpress.Xpf.PropertyGrid

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

Declaration

public IInstanceInitializer NewItemInitializer { get; set; }

Property Value

Type Description
DevExpress.Mvvm.Native.IInstanceInitializer

An object implementing the DevExpress.Mvvm.Native.IInstanceInitializer interface.

Remarks

Use the NewItemInitializer property to initialize a new item and specify which items a user can create. To learn more, see Managing Collection Properties.

Example

The DXPropertyGrid supports adding new objects to collections using the collection editor. To pre-set certain properties for a new object or create an object without the default constructor, use the CollectionDefinition.NewItemInitializer property. Like PropertyDefinitionBase.InstanceInitializer, it should be set to an object that implements the DevExpress.Mvvm.Native.IInstanceInitializer interface.

<Application x:Class="pgrid_collection.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>

    </Application.Resources>
</Application>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the NewItemInitializer property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also