浏览代码

Merge pull request #3575 from AvaloniaUI/fixes/3466-animation-overrides-localvalue

Make animation value override local value
Jumar Macato 5 年之前
父节点
当前提交
6c26b8d3d8
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 1 0
      src/Avalonia.Base/ValueStore.cs
  2. 11 0
      tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_SetValue.cs

+ 1 - 0
src/Avalonia.Base/ValueStore.cs

@@ -232,6 +232,7 @@ namespace Avalonia
                 else
                 else
                 {
                 {
                     var priorityValue = new PriorityValue<T>(_owner, property, this, l);
                     var priorityValue = new PriorityValue<T>(_owner, property, this, l);
+                    priorityValue.SetValue(value, priority);
                     _values.SetValue(property, priorityValue);
                     _values.SetValue(property, priorityValue);
                 }
                 }
             }
             }

+ 11 - 0
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_SetValue.cs

@@ -240,6 +240,17 @@ namespace Avalonia.Base.UnitTests
             Assert.Equal("two", target.GetValue(Class1.FooProperty));
             Assert.Equal("two", target.GetValue(Class1.FooProperty));
         }
         }
 
 
+        [Fact]
+        public void SetValue_Animation_Overrides_LocalValue()
+        {
+            Class1 target = new Class1();
+
+            target.SetValue(Class1.FooProperty, "one", BindingPriority.LocalValue);
+            Assert.Equal("one", target.GetValue(Class1.FooProperty));
+            target.SetValue(Class1.FooProperty, "two", BindingPriority.Animation);
+            Assert.Equal("two", target.GetValue(Class1.FooProperty));
+        }
+
         [Fact]
         [Fact]
         public void Setting_UnsetValue_Reverts_To_Default_Value()
         public void Setting_UnsetValue_Reverts_To_Default_Value()
         {
         {