From 353ad7dbd4d2b6e77b56a23a89c7615ac07f8389 Mon Sep 17 00:00:00 2001 From: Tom Edwards <109803929+TomEdwardsEnscape@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:22:58 +0200 Subject: [PATCH] Add ItemsControl.PreparingContainer event (#14153) --- src/Avalonia.Controls/ItemsControl.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Avalonia.Controls/ItemsControl.cs b/src/Avalonia.Controls/ItemsControl.cs index f7fbf8112d..acc6f4762d 100644 --- a/src/Avalonia.Controls/ItemsControl.cs +++ b/src/Avalonia.Controls/ItemsControl.cs @@ -212,6 +212,15 @@ namespace Avalonia.Controls remove => _childIndexChanged -= value; } + /// + /// Occurs immediately before a container is prepared for use. + /// + /// + /// The prepared element might be newly created or an existing container that is being re- + /// used. + /// + public event EventHandler? PreparingContainer; + /// /// Occurs each time a container is prepared for use. /// @@ -702,6 +711,8 @@ namespace Avalonia.Controls internal void PrepareItemContainer(Control container, object? item, int index) { + PreparingContainer?.Invoke(this, new(container, index)); + // If the container has no theme set, or we've already applied our ItemContainerTheme // (and it hasn't changed since) then we're in control of the container's Theme and may // need to update it.