public BlockContainer(List <LinkDefinition.LinkWrapper> items) //load { Items = new IdeCollection <IdeBaseItem>(this, typeof(IBaseBlock)); foreach (LinkDefinition.LinkWrapper item in items) { if (item.Conditional != null) { if (item.Conditional.switchProperty != null) { Items.Add(new SwitchBlockModel(item, Items)); } else if (item.Conditional.ifNode != null) { Items.Add(new ConditionalBlockModel(item, Items)); } } else if (item.Link != null) { if (item.Link.IsTextLink) { Items.Add(new TextLinkModel(item, Items)); } else { OverlayLinkContainer container; if (!(Items.LastOrDefault() is OverlayLinkContainer)) { container = new OverlayLinkContainer(Items); Items.Add(container); //adds a new link container at the end } else { container = Items.Last() as OverlayLinkContainer; container.Items.CollectionChanged -= (a, b) => { OnContainerChanged?.Invoke(this, b); }; } container.Items.Add(new OverlayLinkModel(item, container.Items)); container.Items.CollectionChanged += (a, b) => { OnContainerChanged?.Invoke(this, b); }; } } else if (item.CardArtCrop != null) { Items.Add(new ArtOverlayBlockModel(item, Items)); } } Items.CollectionChanged += (a, b) => { OnContainerChanged?.Invoke(this, b); }; }