diff --git a/src/Uno.UI.Tests/DependencyProperty/Given_DependencyProperty.cs b/src/Uno.UI.Tests/DependencyProperty/Given_DependencyProperty.cs
index cf70655c69ba..338d7c3533c7 100644
--- a/src/Uno.UI.Tests/DependencyProperty/Given_DependencyProperty.cs
+++ b/src/Uno.UI.Tests/DependencyProperty/Given_DependencyProperty.cs
@@ -1644,6 +1644,13 @@ public void When_Set_With_Both_Style_And_LocalValue()
#endif
}
+ [TestMethod]
+ public void When_DefaultValueOverride()
+ {
+ var SUT = new MyDependencyObjectWithDefaultValueOverride();
+ Assert.AreEqual(42, SUT.GetValue(MyDependencyObjectWithDefaultValueOverride.MyPropertyProperty));
+ }
+
private class MyDependencyObject : FrameworkElement
{
internal static readonly DependencyProperty PropAProperty = DependencyProperty.Register(
@@ -1790,5 +1797,38 @@ private void OnMyNullableChanged(DependencyPropertyChangedEventArgs e)
}
+ partial class MyDependencyObjectWithDefaultValueOverride : DependencyObject
+ {
+ public MyDependencyObjectWithDefaultValueOverride()
+ {
+ this.RegisterDefaultValueProvider(OnProvideDefaultValue);
+ }
+
+ private bool OnProvideDefaultValue(DependencyProperty property, out object defaultValue)
+ {
+ if(property == MyPropertyProperty)
+ {
+ defaultValue = 42;
+
+ return true;
+ }
+
+ defaultValue = null;
+ return false;
+ }
+
+ public int MyProperty
+ {
+ get { return (int)GetValue(MyPropertyProperty); }
+ set { SetValue(MyPropertyProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MyPropertyProperty =
+ DependencyProperty.Register("MyProperty", typeof(int), typeof(MyDependencyObjectWithDefaultValueOverride), new PropertyMetadata(0));
+
+ }
+
+
#endregion
}
diff --git a/src/Uno.UI/UI/Xaml/DependencyPropertyDetails.cs b/src/Uno.UI/UI/Xaml/DependencyPropertyDetails.cs
index d4ace54cce2d..28b0d7652cd7 100644
--- a/src/Uno.UI/UI/Xaml/DependencyPropertyDetails.cs
+++ b/src/Uno.UI/UI/Xaml/DependencyPropertyDetails.cs
@@ -1,4 +1,6 @@
-using System;
+#nullable enable
+
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -13,14 +15,19 @@ namespace Windows.UI.Xaml
///
/// Represents the stack of values used by the Dependency Property Value Precedence system
///
- internal class DependencyPropertyDetails : IEnumerable