// ----------------------------------------------------------------------- // // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- namespace Perspex.Controls { using System; using System.Collections; public class TreeDataTemplate : DataTemplate { public TreeDataTemplate( Func build, Func itemsSelector) : this(o => true, build, itemsSelector) { } public TreeDataTemplate( Type type, Func build, Func itemsSelector) : this(o => IsInstance(o, type), build, itemsSelector) { } public TreeDataTemplate( Func match, Func build, Func itemsSelector) : base(match, build) { this.ItemsSelector = itemsSelector; } public Func ItemsSelector { get; private set; } } public class TreeDataTemplate : TreeDataTemplate { public TreeDataTemplate( Func build, Func itemsSelector) : base(typeof(T), o => build((T)o), o => itemsSelector((T)o)) { } public TreeDataTemplate( Func match, Func build, Func itemsSelector) : base(o => (o is T) ? match((T)o) : false, o => build((T)o), o => itemsSelector((T)o)) { } } }