|
|
|
@ -14,8 +14,6 @@ namespace Perspex.Controls.Templates |
|
|
|
{ |
|
|
|
private readonly Func<object, IEnumerable> _itemsSelector; |
|
|
|
|
|
|
|
private readonly Func<object, bool> _isExpanded; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
|
|
|
|
/// </summary>
|
|
|
|
@ -35,30 +33,6 @@ namespace Perspex.Controls.Templates |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="type">The type of data which the data template matches.</param>
|
|
|
|
/// <param name="build">
|
|
|
|
/// A function which when passed an object of <paramref name="type"/> returns a control.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="itemsSelector">
|
|
|
|
/// A function which when passed an object of <paramref name="type"/> returns the child
|
|
|
|
/// items.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="isExpanded">
|
|
|
|
/// A function which when passed an object of <paramref name="type"/> returns the the
|
|
|
|
/// initial expanded state of the node.
|
|
|
|
/// </param>
|
|
|
|
public FuncTreeDataTemplate( |
|
|
|
Type type, |
|
|
|
Func<object, IControl> build, |
|
|
|
Func<object, IEnumerable> itemsSelector, |
|
|
|
Func<object, bool> isExpanded) |
|
|
|
: this(o => IsInstance(o, type), build, itemsSelector, isExpanded) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
|
|
|
|
/// </summary>
|
|
|
|
@ -75,46 +49,9 @@ namespace Perspex.Controls.Templates |
|
|
|
Func<object, bool> match, |
|
|
|
Func<object, IControl> build, |
|
|
|
Func<object, IEnumerable> itemsSelector) |
|
|
|
: this(match, build, itemsSelector, _ => false) |
|
|
|
{ |
|
|
|
_itemsSelector = itemsSelector; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="match">
|
|
|
|
/// A function which determines whether the data template matches the specified data.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="build">
|
|
|
|
/// A function which when passed a matching object returns a control.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="itemsSelector">
|
|
|
|
/// A function which when passed a matching object returns the child items.
|
|
|
|
/// </param>
|
|
|
|
/// <param name="isExpanded">
|
|
|
|
/// A function which when passed a matching object returns the the initial expanded state
|
|
|
|
/// of the node.
|
|
|
|
/// </param>
|
|
|
|
public FuncTreeDataTemplate( |
|
|
|
Func<object, bool> match, |
|
|
|
Func<object, IControl> build, |
|
|
|
Func<object, IEnumerable> itemsSelector, |
|
|
|
Func<object, bool> isExpanded) |
|
|
|
: base(match, build) |
|
|
|
{ |
|
|
|
_itemsSelector = itemsSelector; |
|
|
|
_isExpanded = isExpanded; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks to see if the item should be initially expanded.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <returns>True if the item should be initially expanded, otherwise false.</returns>
|
|
|
|
public bool IsExpanded(object item) |
|
|
|
{ |
|
|
|
return this?._isExpanded(item) ?? false; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|