diff --git a/src/Controls/src/Core/ListView/ListView.cs b/src/Controls/src/Core/ListView/ListView.cs index ac067b2712d6..73e14502dd54 100644 --- a/src/Controls/src/Core/ListView/ListView.cs +++ b/src/Controls/src/Core/ListView/ListView.cs @@ -8,6 +8,7 @@ using System.Windows.Input; using Microsoft.Extensions.Logging; using Microsoft.Maui.Controls.Internals; +using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Controls.Xaml.Diagnostics; using Microsoft.Maui.Devices; using Microsoft.Maui.Graphics; @@ -151,6 +152,7 @@ protected override void OnBindingContextChanged() } /// + [DoesNotInheritDataType] public BindingBase GroupDisplayBinding { get { return _groupDisplayBinding; } @@ -176,6 +178,7 @@ public DataTemplate GroupHeaderTemplate } /// + [DoesNotInheritDataType] public BindingBase GroupShortNameBinding { get { return _groupShortNameBinding; } diff --git a/src/Controls/src/Core/Picker/Picker.cs b/src/Controls/src/Core/Picker/Picker.cs index 85f282d717c5..cfc071ad248e 100644 --- a/src/Controls/src/Core/Picker/Picker.cs +++ b/src/Controls/src/Core/Picker/Picker.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using Microsoft.Maui.Controls.Internals; +using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Graphics; namespace Microsoft.Maui.Controls @@ -199,6 +200,7 @@ public TextAlignment VerticalTextAlignment BindingBase _itemDisplayBinding; /// + [DoesNotInheritDataType] public BindingBase ItemDisplayBinding { get { return _itemDisplayBinding; } diff --git a/src/Controls/src/Core/TemplatedItemsList.cs b/src/Controls/src/Core/TemplatedItemsList.cs index a90d29d71212..d4c2bd035313 100644 --- a/src/Controls/src/Core/TemplatedItemsList.cs +++ b/src/Controls/src/Core/TemplatedItemsList.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Cadenza.Collections; using Microsoft.Maui.Controls.Internals; +using Microsoft.Maui.Controls.Xaml; using Microsoft.Maui.Devices; namespace Microsoft.Maui.Controls.Internals @@ -100,6 +101,7 @@ event PropertyChangedEventHandler ITemplatedItemsList.PropertyChanged remove { PropertyChanged -= value; } } + [DoesNotInheritDataType] public BindingBase GroupDisplayBinding { get { return _groupDisplayBinding; } @@ -133,6 +135,7 @@ public DataTemplate GroupHeaderTemplate public BindableProperty GroupHeaderTemplateProperty { get; set; } + [DoesNotInheritDataType] public BindingBase GroupShortNameBinding { get { return _groupShortNameBinding; } diff --git a/src/Controls/src/Core/Xaml/DoesNotInheritDataTypeAttribute.cs b/src/Controls/src/Core/Xaml/DoesNotInheritDataTypeAttribute.cs new file mode 100644 index 000000000000..6c1f785c6f2d --- /dev/null +++ b/src/Controls/src/Core/Xaml/DoesNotInheritDataTypeAttribute.cs @@ -0,0 +1,9 @@ +#nullable disable +using System; + +namespace Microsoft.Maui.Controls.Xaml +{ + internal class DoesNotInheritDataTypeAttribute : Attribute + { + } +} diff --git a/src/Controls/src/Xaml/XamlServiceProvider.cs b/src/Controls/src/Xaml/XamlServiceProvider.cs index c2b86f47db39..5b2e3bbbd9e2 100644 --- a/src/Controls/src/Xaml/XamlServiceProvider.cs +++ b/src/Controls/src/Xaml/XamlServiceProvider.cs @@ -324,7 +324,7 @@ static bool IsBindingContextBinding(IElementNode node) return false; } - static bool IsBindingBaseProperty(IElementNode node, HydrationContext context) + static bool DoesNotInheritDataType(IElementNode node, HydrationContext context) { if ( node.TryGetPropertyName(node.Parent, out XmlName name) && node.Parent is IElementNode parent @@ -332,9 +332,9 @@ static bool IsBindingBaseProperty(IElementNode node, HydrationContext context) new XmlLineInfo(((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition), context.RootElement.GetType().Assembly, out var xpe) is Type parentType && parentType.GetRuntimeProperties().FirstOrDefault(p => p.Name == name.LocalName) is PropertyInfo propertyInfo - && propertyInfo.PropertyType == typeof(BindingBase)) + && propertyInfo.CustomAttributes.Any(ca => ca.AttributeType == typeof(DoesNotInheritDataTypeAttribute))) { - return true; + return true; } return false; } @@ -360,7 +360,7 @@ static bool IsBindingBaseProperty(IElementNode node, HydrationContext context) { break; } - if (IsBindingBaseProperty(n, context)) + if (DoesNotInheritDataType(n, context)) { break; }