Sfoglia il codice sorgente

Fixed templated parent theme changed loop.

José Pedro 2 anni fa
parent
commit
12bf8bd181

+ 17 - 0
src/Avalonia.Base/Visual.cs

@@ -732,6 +732,23 @@ namespace Avalonia
             }
         }
 
+        internal override void OnTemplatedParentControlThemeChanged()
+        {
+            base.OnTemplatedParentControlThemeChanged();
+
+            var count = VisualChildren.Count;
+            var templatedParent = TemplatedParent;
+
+            for (var i = 0; i < count; ++i)
+            {
+                if (VisualChildren[i] is StyledElement child &&
+                    child.TemplatedParent == templatedParent)
+                {
+                    child.OnTemplatedParentControlThemeChanged();
+                }
+            }
+        }
+
         /// <summary>
         /// Computes the <see cref="HasMirrorTransform"/> value according to the 
         /// <see cref="FlowDirection"/> and <see cref="BypassFlowDirectionPolicies"/>

+ 0 - 17
src/Avalonia.Controls/Primitives/TemplatedControl.cs

@@ -405,22 +405,5 @@ namespace Avalonia.Controls.Primitives
                 }
             }
         }
-
-        internal override void OnTemplatedParentControlThemeChanged()
-        {
-            base.OnTemplatedParentControlThemeChanged();
-
-            var count = VisualChildren.Count;
-            var templatedParent = TemplatedParent;
-
-            for (var i = 0; i < count; ++i)
-            {
-                if (VisualChildren[i] is TemplatedControl child &&
-                    child.TemplatedParent == templatedParent)
-                {
-                    child.OnTemplatedParentControlThemeChanged();
-                }
-            }
-        }
     }
 }