Поделиться через


PagedCollectionView.AddNew Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Adds a new item to the underlying collection.

Namespace:  System.Windows.Data
Assembly:  System.Windows.Data (in System.Windows.Data.dll)

Syntax

'Declaration
Public Function AddNew As Object
public Object AddNew()

Return Value

Type: System.Object
The new item that is being added.

Implements

IEditableCollectionView.AddNew()

Exceptions

Exception Condition
InvalidOperationException

CanAddNew is false.

Remarks

After calling AddNew and changing the new item as needed, you should call either CommitNew or CancelNew to complete the transaction. Calling AddNew before a previous add or edit transaction has been committed or canceled will cause the previous transaction to be committed. The new item will always appear in the collection view. Any filtering, sorting, or grouping that is applied to the view is applied to the new item when CommitNew is called.

Use the CanAddNew property to test whether a new item can be added before you call AddNew.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.