IEditableCollectionView.CanRemove 속성

정의

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

public:
 property bool CanRemove { bool get(); };
public bool CanRemove { get; }
member this.CanRemove : bool
Public ReadOnly Property CanRemove As Boolean

속성 값

컬렉션에서 항목을 제거할 수 있으면 true이고, 제거할 수 없으면 false입니다.

예제

다음 예제에서는 CanRemove 컬렉션에서 항목을 제거할 수 있는지 여부를 확인 합니다. 이 예제에서는 호출 동작을 확인 하 라는 항목을 제거할 수 있으면 Remove 를 클릭 하면 합니다. 전체 샘플을 보려면 IEditableCollectionView 예제를 사용 하 여 컬렉션을 변경합니다.

IEditableCollectionView editableCollectionView = 
        itemsControl.Items as IEditableCollectionView; 

if (!editableCollectionView.CanRemove)
{
    MessageBox.Show("You cannot remove items from the list.");
    return;
}

if (MessageBox.Show("Are you sure you want to remove " + item.Description,
                    "Remove Item", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
    editableCollectionView.Remove(itemsControl.SelectedItem);
}
Dim editableCollectionView As IEditableCollectionView = TryCast(itemsControl.Items, IEditableCollectionView)

If Not editableCollectionView.CanRemove Then
    MessageBox.Show("You cannot remove items from the list.")
    Return
End If

If MessageBox.Show("Are you sure you want to remove " & item.Description, "Remove Item", MessageBoxButton.YesNo) = MessageBoxResult.Yes Then
    editableCollectionView.Remove(itemsControl.SelectedItem)
End If

설명

CanRemovefalse 기본 컬렉션이 읽기 전용인 경우.

적용 대상