Browse Source

Change StylingParent for Popup to be PopupRoot so local styles flow to it.

Jeremy Koritzinsky 8 years ago
parent
commit
8bcd07730a

+ 2 - 2
src/Avalonia.Controls/Primitives/PopupRoot.cs

@@ -17,7 +17,7 @@ namespace Avalonia.Controls.Primitives
     /// <summary>
     /// The root window of a <see cref="Popup"/>.
     /// </summary>
-    public class PopupRoot : WindowBase, IInteractive, IHostedVisualTreeRoot, IDisposable, IResourceNode
+    public class PopupRoot : WindowBase, IInteractive, IHostedVisualTreeRoot, IDisposable, IStyleHost
     {
         private IDisposable _presenterSubscription;
 
@@ -70,7 +70,7 @@ namespace Avalonia.Controls.Primitives
         /// <summary>
         /// Gets the styling parent of the popup root.
         /// </summary>
-        IResourceNode IResourceNode.ResourceParent => Parent;
+        IStyleRoot IStyleHost.StylingParent => Parent;
 
         /// <inheritdoc/>
         public void Dispose() => PlatformImpl?.Dispose();

+ 1 - 1
tests/Avalonia.Controls.UnitTests/ControlTests_Resources.cs

@@ -168,7 +168,7 @@ namespace Avalonia.Controls.UnitTests
             target.Resources.Add("foo", "bar");
 
             Assert.True(raisedOnTarget);
-            Assert.False(raisedOnPresenter);
+            Assert.True(raisedOnPresenter);
             Assert.True(raisedOnChild);
         }
 

+ 2 - 2
tests/Avalonia.Controls.UnitTests/Primitives/PopupRootTests.cs

@@ -39,7 +39,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
         }
 
         [Fact]
-        public void PopupRoot_ResourceParent_Is_Popup()
+        public void PopupRoot_StylingParent_Is_Popup()
         {
             using (UnitTestApplication.Start(TestServices.StyledWindow))
             {
@@ -53,7 +53,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
                 target.ApplyTemplate();
                 target.Popup.Open();
 
-                Assert.Equal(target.Popup, ((IResourceNode)target.Popup.PopupRoot).ResourceParent);
+                Assert.Equal(target.Popup, ((IStyleHost)target.Popup.PopupRoot).StylingParent);
             }
         }