IEditableCollectionView.CanRemove Property


Gets a value that indicates whether an item can be removed from the collection.

Namespace:   System.ComponentModel
Assembly:  WindowsBase (in WindowsBase.dll)

ReadOnly Property CanRemove As Boolean

Property Value

Type: System.Boolean

true if an item can be removed from the collection; otherwise, false.

CanRemove is false if the underlying collection is read-only.

The following example calls CanRemove to check whether an item can be removed from the collection. If an item can be removed, the example prompts the user to confirm the action and calls Remove if the user clicks Yes. For the entire sample, see Changing a Collection by Using IEditableCollectionView Sample.

Dim editableCollectionView As IEditableCollectionView = TryCast(itemsControl.Items, IEditableCollectionView)

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

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

.NET Framework
Available since 3.0
Available since 3.0
Windows Phone Silverlight
Available since 7.1
Return to top