What does OP mean by instance? List definition in XML? In that case maybe not, but there is code for that which I have successfully used many a time. Just stick that in an event receiver and you're good to go:
public static void AddCalendarOverlay(SPList targetList, string viewName, SPList overlayList, string overlayListView, string overlayName, string overlayDescription, CalendarOverlayColor color, bool alwaysShow, bool clearExisting)
{
bool sharePoint = overlayList != null;
SPView overlayView = overlayList.DefaultView;
if (!string.IsNullOrEmpty(overlayListView))
{
if (overlayList.Views[overlayListView] != null)
{
overlayView = overlayList.Views[overlayListView];
}
}
string linkUrl = overlayView.ServerRelativeUrl;
SPView targetView = targetList.DefaultView;
if (!string.IsNullOrEmpty(viewName))
{
if (targetList.Views[viewName] != null)
{
targetView = targetList.Views[viewName];
}
}
XmlDocument xml = new XmlDocument();
XmlElement aggregationElement = null;
int count = 0;
if (string.IsNullOrEmpty(targetView.CalendarSettings) || clearExisting)
{
xml.AppendChild(xml.CreateElement("AggregationCalendars"));
aggregationElement = xml.CreateElement("AggregationCalendar");
xml.DocumentElement.AppendChild(aggregationElement);
}
else
{
xml.LoadXml(targetView.CalendarSettings);
XmlNodeList calendars = xml.SelectNodes("/AggregationCalendars/AggregationCalendar");
if (calendars != null)
count = calendars.Count;
aggregationElement = xml.SelectSingleNode(string.Format("/AggregationCalendars/AggregationCalendar[@CalendarUrl='{0}']", linkUrl)) as XmlElement;
if (aggregationElement == null)
{
if (count >= 10)
throw new SPException(string.Format("10 calendar ovarlays already exist for the calendar {0}.", targetList.RootFolder.ServerRelativeUrl));
aggregationElement = xml.CreateElement("AggregationCalendar");
xml.DocumentElement.AppendChild(aggregationElement);
}
}
if (!aggregationElement.HasAttribute("Id"))
aggregationElement.SetAttribute("Id", Guid.NewGuid().ToString("B", CultureInfo.InvariantCulture));
aggregationElement.SetAttribute("Type", sharePoint ? "SharePoint" : "Exchange");
aggregationElement.SetAttribute("Name", !string.IsNullOrEmpty(overlayName) ? overlayName : (overlayList == null ? "" : overlayList.Title));
aggregationElement.SetAttribute("Description", !string.IsNullOrEmpty(overlayDescription) ? overlayDescription : (overlayList == null ? "" : overlayList.Description));
aggregationElement.SetAttribute("Color", ((int)color).ToString());
aggregationElement.SetAttribute("AlwaysShow", alwaysShow.ToString());
aggregationElement.SetAttribute("CalendarUrl", linkUrl);
XmlElement settingsElement = aggregationElement.SelectSingleNode("./Settings") as XmlElement;
if (settingsElement == null)
{
settingsElement = xml.CreateElement("Settings");
aggregationElement.AppendChild(settingsElement);
}
if (sharePoint)
{
settingsElement.SetAttribute("WebUrl", overlayList.ParentWeb.Site.MakeFullUrl(overlayList.ParentWebUrl));
settingsElement.SetAttribute("ListId", overlayList.ID.ToString("B", CultureInfo.InvariantCulture));
settingsElement.SetAttribute("ViewId", overlayView.ID.ToString("B", CultureInfo.InvariantCulture));
settingsElement.SetAttribute("ListFormUrl", overlayList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl);
}
targetView.CalendarSettings = xml.OuterXml;
targetView.Update();
}
Most of the code is self-explanatory, but if you need any clarification I will be happy to help.