浏览代码

Fixed templated parent theme changed loop.

José Pedro 2 年之前
父节点
当前提交
12bf8bd181
共有 2 个文件被更改,包括 17 次插入17 次删除
  1. 17 0
      src/Avalonia.Base/Visual.cs
  2. 0 17
      src/Avalonia.Controls/Primitives/TemplatedControl.cs

+ 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>
         /// <summary>
         /// Computes the <see cref="HasMirrorTransform"/> value according to the 
         /// Computes the <see cref="HasMirrorTransform"/> value according to the 
         /// <see cref="FlowDirection"/> and <see cref="BypassFlowDirectionPolicies"/>
         /// <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();
-                }
-            }
-        }
     }
     }
 }
 }