IEditableCollectionView 인터페이스

정의

CollectionView가 컬렉션에 편집 기능을 제공하기 위해 구현하는 메서드 및 속성을 정의합니다.

public interface class IEditableCollectionView
public interface IEditableCollectionView
type IEditableCollectionView = interface
Public Interface IEditableCollectionView
파생

예제

다음 예제에서는 정의한 메서드를 사용 하 여 컬렉션에 항목을 추가 하는 방법을 보여 줍니다 IEditableCollectionView합니다. 이 애플리케이션 판매에 대 한 항목의 목록을 표시 하 고 사용자 추가, 편집 또는 제거 항목의 옵션을 제공 합니다. 사용자 추가, 항목을 편집 하는 경우 폼 새 항목을 입력 하 라는 메시지가 표시 됩니다. 사용자가 폼을 제출 하는 경우 항목 컬렉션에 커밋됩니다. 사용자가 폼을 취소 하는 경우 항목이 삭제 됩니다. 전체 샘플을 보려면 IEditableCollectionView 예제를 사용 하 여 컬렉션을 변경합니다.

IEditableCollectionView editableCollectionView = 
    itemsControl.Items as IEditableCollectionView; 

if (!editableCollectionView.CanAddNew)
{
    MessageBox.Show("You cannot add items to the list.");
    return;
}

// Create a window that prompts the user to enter a new
// item to sell.
ChangeItemWindow win = new ChangeItemWindow();

//Create a new item to be added to the collection.
win.DataContext = editableCollectionView.AddNew();

// If the user submits the new item, commit the new
// object to the collection.  If the user cancels 
// adding the new item, discard the new item.
if ((bool)win.ShowDialog())
{
    editableCollectionView.CommitNew();
}
else
{
    editableCollectionView.CancelNew();
}
Dim editableCollectionView As IEditableCollectionView = TryCast(itemsControl.Items, IEditableCollectionView)

If Not editableCollectionView.CanAddNew Then
    MessageBox.Show("You cannot add items to the list.")
    Return
End If

' Create a window that prompts the user to enter a new
' item to sell.
Dim win As New ChangeItemWindow()

'Create a new item to be added to the collection.
win.DataContext = editableCollectionView.AddNew()

' If the user submits the new item, commit the new
' object to the collection.  If the user cancels 
' adding the new item, discard the new item.
If CBool(win.ShowDialog()) Then
    editableCollectionView.CommitNew()
Else
    editableCollectionView.CancelNew()
End If

설명

컬렉션 뷰를 구현 하는 경우는 IEditableCollectionView 인터페이스를 직접 변경할 수 있습니다 기본 컬렉션을 메서드 및 속성을 사용 하 여 변경할 수 있도록 하는 경우는 IEditableCollectionView 컬렉션의 형식에 관계 없이 표시 합니다.

형식 ItemCollection, BindingListCollectionViewListCollectionView 는 에서 CollectionView상속되는 WPF(Windows Presentation Foundation)와 함께 제공되는 형식입니다. 이러한 형식은 또한 구현 하는 IEditableCollectionView이므로 이러한 형식 중 하나를 사용 하는 컬렉션을 편집할 수 있습니다. ItemCollection특히 흔히 때문에 합니다 ItemsControl.Items 속성이 ItemCollection합니다.

속성

CanAddNew

컬렉션에 새 항목을 추가할 수 있는지 여부를 나타내는 값을 가져옵니다.

CanCancelEdit

컬렉션 뷰에서 보류 중인 변경 내용을 삭제하고 편집된 개체의 원래 값을 복원할 수 있는지 여부를 나타내는 값을 가져옵니다.

CanRemove

컬렉션에서 항목을 제거할 수 있는지 여부를 나타내는 값을 가져옵니다.

CurrentAddItem

현재 추가 트랜잭션 중에 추가되는 항목을 가져옵니다.

CurrentEditItem

편집되는 컬렉션의 항목을 가져옵니다.

IsAddingNew

추가 트랜잭션이 진행 중인지 여부를 나타내는 값을 가져옵니다.

IsEditingItem

편집 트랜잭션이 진행 중인지 여부를 나타내는 값을 가져옵니다.

NewItemPlaceholderPosition

컬렉션 뷰에서의 새 항목 자리 표시자 위치를 가져오거나 설정합니다.

메서드

AddNew()

컬렉션에 새 항목을 추가합니다.

CancelEdit()

편집 트랜잭션을 끝내고 가능한 경우 항목의 원래 값을 복원합니다.

CancelNew()

추가 트랜잭션을 끝내고 보류 중인 새 항목을 삭제합니다.

CommitEdit()

편집 트랜잭션을 끝내고 보류 중인 변경 내용을 저장합니다.

CommitNew()

추가 트랜잭션을 끝내고 보류 중인 새 항목을 저장합니다.

EditItem(Object)

지정된 항목에 대해 편집 트랜잭션을 시작합니다.

Remove(Object)

컬렉션에서 지정한 항목을 제거합니다.

RemoveAt(Int32)

컬렉션에서 지정된 위치의 항목을 제거합니다.

적용 대상