Now the PageDataCollection PropertyMultiPage.SelectedPages will be updated every time a change happens in EPiServer. The MultiPageProperty.SelectedPages was implemented like this:

public PageDataCollection SelectedPages
{
get
{
if (_selectedPages == null)
_selectedPages = new PageDataCollection();

// When serializing using WebParts, the private member will
// be initialized, I think! Because of this, the LongString is
// never parsed. We'll always try to parse if the count is 0.
// The performance impact should be minimal (if the actual count
// is 0, the string should be empty anyway.)
if (_selectedPages.Count == 0)
{
// Do the regular stuff
}
return _selectedPages;
}
set
{
_selectedPages = value;
}
}

The problem here is that when you make changes to one of the pages stored in SelectedPages, e.g you change the MainIntro Property, this change will not be reflected in the page stored in PageDataCollection SelectedPages. Why?! The new ReadOnly page cache introduced in EPiServer CMS 5. The pages in SelectedPages are copies (CreateWritableClone is used) of the original pages, and are not updated when the original page is updated. After having a discussion with a colleague of mine, Lars Sørensen, and Steve Celius at EPiServer Norway, we came up with this solution:

private long _versionKey;
public long VersionKey
{
get { return _versionKey; }
set { _versionKey = value; }
}

/// <summary>
/// Gets the collection of pages that
/// the user has selected with the property control
/// </summary>
[XmlIgnore]
public PageDataCollection SelectedPages
{
get
{
// Don`t parse the LongString if nothing has been updated in EPiServer
if (_versionKey != DataFactoryCache.Version)
{
_selectedPages = new PageDataCollection();
// Do the regular stuff

// Set the versionkey
_versionKey = DataFactoryCache.Version;
}
return _selectedPages;
}
set
{
_selectedPages = value;
}
}

The new code has been committed to Epicode. So if you are using the MultiPageProperty in one of your EPiServer CMS 5 projects, I would recommend that you go to CodeResort and download the latest update!

A big thank you to Lars and Steve for contributing to this nice solution!