diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs index a1da97e824..4046915986 100644 --- a/src/Avalonia.Base/AvaloniaObject.cs +++ b/src/Avalonia.Base/AvaloniaObject.cs @@ -228,6 +228,10 @@ namespace Avalonia /// /// The property. /// True if the property is set, otherwise false. + /// + /// 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 . + /// public bool IsSet(AvaloniaProperty property) { Contract.Requires(property != null); diff --git a/src/Avalonia.Base/PriorityValue.cs b/src/Avalonia.Base/PriorityValue.cs index 715fca3915..0dd18d852a 100644 --- a/src/Avalonia.Base/PriorityValue.cs +++ b/src/Avalonia.Base/PriorityValue.cs @@ -77,7 +77,6 @@ namespace Avalonia /// /// The binding. /// The binding priority. - /// Validation settings for the binding. /// /// A disposable that will remove the binding. /// diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs index 7d8528c5d7..ed826f64e4 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests.cs +++ b/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(); 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;