From 78a7257a5a3a0cd33ad77382d4d0c29759263dfa Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 9 Jul 2022 12:32:22 +0200 Subject: [PATCH] Don't apply templated parent if already set. When applying the `TemplatedParent`, don't move into trees that already have the `TemplatedParent` property set - in this case we can assume that the templated parent has already been set for this tree, and it fixes the problem with menus added in the previous commit. --- src/Avalonia.Controls/Primitives/TemplatedControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs index 4403bfce51..c3e0f3e523 100644 --- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs +++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs @@ -396,7 +396,7 @@ namespace Avalonia.Controls.Primitives for (var i = 0; i < count; i++) { - if (children[i] is IStyledElement child) + if (children[i] is IStyledElement child && child.TemplatedParent is null) { ApplyTemplatedParent(child, templatedParent); }