1
0
Эх сурвалжийг харах

Updated some docs.

And simplified a bit of failing test code.
Steven Kirk 9 жил өмнө
parent
commit
0d4a613580

+ 4 - 0
src/Avalonia.Base/AvaloniaObject.cs

@@ -228,6 +228,10 @@ namespace Avalonia
         /// </summary>
         /// <param name="property">The property.</param>
         /// <returns>True if the property is set, otherwise false.</returns>
+        /// <remarks>
+        /// Checks whether a value is assigned to the property, or that there is a binding to the
+        /// property that is producing a value other than <see cref="AvaloniaProperty.UnsetValue"/>.
+        /// </remarks>
         public bool IsSet(AvaloniaProperty property)
         {
             Contract.Requires<ArgumentNullException>(property != null);

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

@@ -77,7 +77,6 @@ namespace Avalonia
         /// </summary>
         /// <param name="binding">The binding.</param>
         /// <param name="priority">The binding priority.</param>
-        /// <param name="validation">Validation settings for the binding.</param>
         /// <returns>
         /// A disposable that will remove the binding.
         /// </returns>

+ 7 - 2
tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs

@@ -170,11 +170,16 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data
             };
 
             var child = new Control();
-            var dataContextBinding = new Binding("Foo");
             var values = new List<object>();
 
             child.GetObservable(Border.DataContextProperty).Subscribe(x => values.Add(x));
-            child.Bind(ContentControl.DataContextProperty, dataContextBinding);
+            child.Bind(Control.DataContextProperty, new Binding("Foo"));
+
+            // When binding to DataContext and the target isn't found, the binding should produce
+            // null rather than UnsetValue in order to not propagate incorrect DataContexts from
+            // parent controls while things are being set up. This logic is implemented in 
+            // `Avalonia.Markup.Xaml.Binding.Initiate`.
+            Assert.True(child.IsSet(Control.DataContextProperty));
 
             root.Child = child;