Share via


XamlDirect.RemoveFromCollection(IXamlDirectObject, IXamlDirectObject) Method

Definition

Tries to remove a value from the specified IXamlDirectObject collection.

public:
 virtual bool RemoveFromCollection(IXamlDirectObject ^ xamlDirectObject, IXamlDirectObject ^ value) = RemoveFromCollection;
bool RemoveFromCollection(IXamlDirectObject const& xamlDirectObject, IXamlDirectObject const& value);
public bool RemoveFromCollection(IXamlDirectObject xamlDirectObject, IXamlDirectObject value);
function removeFromCollection(xamlDirectObject, value)
Public Function RemoveFromCollection (xamlDirectObject As IXamlDirectObject, value As IXamlDirectObject) As Boolean

Parameters

xamlDirectObject
IXamlDirectObject

Refers to the specific IXamlDirectObject collection.

value
IXamlDirectObject

Refers to the IXamlDirectObject value to remove from the collection.

Returns

Boolean

bool

true if value was present. false if value was not present.

Examples

The following example shows how to remove a value from a collection using XamlDirect APIs.

XamlDirect xd = XamlDirect.GetDefault();

IXamlDirectObject relativePanel = xd.CreateInstance(XamlTypeIndex.RelativePanel);

IXamlDirectObject childrenCollection = xd.GetXamlDirectObjectProperty(relativePanel, XamlPropertyIndex.Panel_Children);

IXamlDirectObject button = xd.CreateInstance(XamlTypeIndex.Button);
xd.AddToCollection(childrenCollection, button);

xd.RemoveFromCollection(childrenCollection, button); // Should return true
xd.RemoveFromCollection(childrenCollection, button); // Should return false
XamlDirect^ xd = XamlDirect::GetDefault();

IXamlDirectObject^ relativePanel = xd->CreateInstance(XamlTypeIndex::RelativePanel);

IXamlDirectObject^ childrenCollection = xd->GetXamlDirectObjectProperty(relativePanel, XamlPropertyIndex::Panel_Children);

IXamlDirectObject^ button = xd->CreateInstance(XamlTypeIndex::Button);
xd->AddToCollection(childrenCollection, button);

xd->RemoveFromCollection(childrenCollection, button); // Should return true
xd->RemoveFromCollection(childrenCollection, button); // Should return false

Applies to

See also