IEditableCollectionView.CanRemove Property

Updated: July 2008

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

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

bool CanRemove { get; }
You cannot set this property in XAML.

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.

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);
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP2

Date

History

Reason

July 2008

Added topic for new interface.

SP1 feature change.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft