I was writing a scheduled job to move items from a ContentArea in a local block to a ContentArea on the actual page. Copying the items was no problem, but removing them from the old contentarea was more of a challenge. What I expected to work was to call writableClone.LocalBlock.ContentArea.Items.Clear(). This had no effect however. Eventually I resorted to create a temporary list of ContentAreaItems to delete, and then call writableClone.LocalBlock.ContentArea.Items.Remove(contentAreaItemToDelete) for each item.
<p>If you take a deeper look on how content area Items are implemented then you can see that there is an observable collection of items with collection change event handler built out of current Fragments. I guess that direct .Clear() should not have any effect. You have to remove item by item to notify subscribers. That's exactly what CMS UI does.</p>
Hi,
I was writing a scheduled job to move items from a ContentArea in a local block to a ContentArea on the actual page. Copying the items was no problem, but removing them from the old contentarea was more of a challenge. What I expected to work was to call writableClone.LocalBlock.ContentArea.Items.Clear(). This had no effect however. Eventually I resorted to create a temporary list of ContentAreaItems to delete, and then call writableClone.LocalBlock.ContentArea.Items.Remove(contentAreaItemToDelete) for each item.
Shouldn't Items.Clear() have sealed the deal?