diff --git a/Xamarin.Forms.Core.UnitTests/BindableObjectUnitTests.cs b/Xamarin.Forms.Core.UnitTests/BindableObjectUnitTests.cs index 76896bcef..a4e81a24c 100644 --- a/Xamarin.Forms.Core.UnitTests/BindableObjectUnitTests.cs +++ b/Xamarin.Forms.Core.UnitTests/BindableObjectUnitTests.cs @@ -891,7 +891,7 @@ namespace Xamarin.Forms.Core.UnitTests } [Test] - public void IsSetIsTrueWhenPropCleared() + public void IsSetIsFalseWhenPropCleared() { string defaultValue = "default"; string newValue = "new value"; @@ -900,11 +900,9 @@ namespace Xamarin.Forms.Core.UnitTests var bindable = new MockBindable(); bindable.SetValue(bindableProperty, newValue); - bindable.ClearValue(bindableProperty); - var isSet = bindable.IsSet(bindableProperty); - Assert.IsTrue(isSet); + Assert.That(bindable.IsSet(bindableProperty), Is.False); } [Test] @@ -924,7 +922,7 @@ namespace Xamarin.Forms.Core.UnitTests } [Test] - public void IsSetIsTrueWhenPropSetByDefaultValueCreator() + public void IsSetIsFalseWhenPropSetByDefaultValueCreator() { string defaultValue = "default"; string defaultValueC = "defaultVC"; @@ -941,7 +939,7 @@ namespace Xamarin.Forms.Core.UnitTests Assert.AreEqual(defaultValueC, created); var isSet = bindable.IsSet(bindableProperty); - Assert.IsTrue(isSet); + Assert.IsFalse(isSet); } [Test] @@ -1552,4 +1550,4 @@ namespace Xamarin.Forms.Core.UnitTests Assert.That(() => binding.Path = "Foo", Throws.Nothing); } } -} \ No newline at end of file +} diff --git a/Xamarin.Forms.Core/BindableObject.cs b/Xamarin.Forms.Core/BindableObject.cs index 7b1686fc0..343868498 100644 --- a/Xamarin.Forms.Core/BindableObject.cs +++ b/Xamarin.Forms.Core/BindableObject.cs @@ -57,7 +57,9 @@ namespace Xamarin.Forms if (targetProperty == null) throw new ArgumentNullException(nameof(targetProperty)); - return GetContext(targetProperty) != null; + var bpcontext = GetContext(targetProperty); + return bpcontext != null + && (bpcontext.Attributes & BindableContextAttributes.IsDefaultValue) == 0; } public object GetValue(BindableProperty property) @@ -178,14 +180,6 @@ namespace Xamarin.Forms return bpcontext != null && bpcontext.Binding != null; } - internal bool GetIsDefault(BindableProperty targetProperty) - { - if (targetProperty == null) - throw new ArgumentNullException(nameof(targetProperty)); - - return GetContext(targetProperty) == null; - } - [EditorBrowsable(EditorBrowsableState.Never)] public object[] GetValues(BindableProperty property0, BindableProperty property1) { diff --git a/Xamarin.Forms.Core/FlexLayout.cs b/Xamarin.Forms.Core/FlexLayout.cs index 247c52f2a..9e2b170ac 100644 --- a/Xamarin.Forms.Core/FlexLayout.cs +++ b/Xamarin.Forms.Core/FlexLayout.cs @@ -123,35 +123,35 @@ namespace Xamarin.Forms static void OnOrderPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable.GetIsDefault(FlexItemProperty)) + if (!bindable.IsSet(FlexItemProperty)) return; GetFlexItem(bindable).Order = (int)newValue; } static void OnGrowPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable.GetIsDefault(FlexItemProperty)) + if (!bindable.IsSet(FlexItemProperty)) return; GetFlexItem(bindable).Grow = (float)newValue; } static void OnShrinkPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable.GetIsDefault(FlexItemProperty)) + if (!bindable.IsSet(FlexItemProperty)) return; GetFlexItem(bindable).Shrink = (float)newValue; } static void OnAlignSelfPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable.GetIsDefault(FlexItemProperty)) + if (!bindable.IsSet(FlexItemProperty)) return; GetFlexItem(bindable).AlignSelf = (Flex.AlignSelf)(FlexAlignSelf)newValue; } static void OnBasisPropertyChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable.GetIsDefault(FlexItemProperty)) + if (!bindable.IsSet(FlexItemProperty)) return; GetFlexItem(bindable).Basis = ((FlexBasis)newValue).ToFlexBasis(); } diff --git a/Xamarin.Forms.Core/VisualStateManager.cs b/Xamarin.Forms.Core/VisualStateManager.cs index 10f2f8e7b..cc5b3cc8e 100644 --- a/Xamarin.Forms.Core/VisualStateManager.cs +++ b/Xamarin.Forms.Core/VisualStateManager.cs @@ -38,7 +38,7 @@ namespace Xamarin.Forms public static bool GoToState(VisualElement visualElement, string name) { - if (visualElement.GetIsDefault(VisualStateGroupsProperty)) + if (!visualElement.IsSet(VisualStateGroupsProperty)) { return false; } @@ -86,7 +86,7 @@ namespace Xamarin.Forms public static bool HasVisualStateGroups(this VisualElement element) { - return !element.GetIsDefault(VisualStateGroupsProperty); + return element.IsSet(VisualStateGroupsProperty); } }