Browse Source
In #4218 we imported `IElementFactory` from WinUI which is broadly analogous to a recycling datatemplate for lists. In Avalonia this implement `IDataTemplate` in order to have a common base class for all types of data templates. The problem with this is that `IDataTemplate` already had a `SupportsRecycling` property which is incompatible with the way recycling is implemented in `IElementFactory`. Instead, introduce an `IRecyclingDataTemplate` to signal data templates that support recycling.pull/4271/head
12 changed files with 71 additions and 43 deletions
@ -0,0 +1,25 @@ |
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls.Templates |
|||
{ |
|||
/// <summary>
|
|||
/// An <see cref="IDataTemplate"/> that supports recycling existing elements.
|
|||
/// </summary>
|
|||
public interface IRecyclingDataTemplate : IDataTemplate |
|||
{ |
|||
/// <summary>
|
|||
/// Creates or recycles a control to display the specified data.
|
|||
/// </summary>
|
|||
/// <param name="data">The data to display.</param>
|
|||
/// <param name="existing">An optional control to recycle.</param>
|
|||
/// <returns>
|
|||
/// The <paramref name="existing"/> control if supplied and applicable to
|
|||
/// <paramref name="data"/>, otherwise a new control.
|
|||
/// </returns>
|
|||
/// <remarks>
|
|||
/// The caller should ensure that any control passed to <paramref name="existing"/>
|
|||
/// originated from the same data template.
|
|||
/// </remarks>
|
|||
IControl Build(object data, IControl? existing); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue