// ----------------------------------------------------------------------- // // Copyright 2015 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Controls.Generators { using Perspex.Controls.Templates; /// /// Creates containers for items and maintains a list of created containers. /// /// The type of the container. public class ItemContainerGenerator : ItemContainerGenerator where T : class, IContentControl, new() { /// /// Initializes a new instance of the class. /// /// The owner control. public ItemContainerGenerator(Control owner) : base(owner) { } /// protected override IControl CreateContainer(object item, IDataTemplate itemTemplate) { T result = item as T; if (result == null) { result = new T(); result.Content = this.Owner.MaterializeDataTemplate(item); } return result; } } }