internal override void SetUp(BindableObject bindable) { if (Binding != null) { bindable.SetBinding(_boundProperty, Binding.Clone()); } }
static void BindProperty(BindableObject content, BindableProperty property, Type type) { if (content.IsSet(property) || content.GetIsBound(property)) { // Don't override the property if user has already set it return; } content.SetBinding(property, new Binding(property.PropertyName, source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor, type))); }
/// <include file="../../docs/Microsoft.Maui.Controls/BindableObjectExtensions.xml" path="//Member[@MemberName='SetBinding']/Docs" /> public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, string stringFormat = null) { if (self == null) { throw new ArgumentNullException("self"); } if (targetProperty == null) { throw new ArgumentNullException("targetProperty"); } var binding = new Binding(path, mode, converter, stringFormat: stringFormat); self.SetBinding(targetProperty, binding); }
/// <include file="../../docs/Microsoft.Maui.Controls/BindableObjectExtensions.xml" path="//Member[@MemberName='SetOnAppTheme']/Docs" /> public static void SetOnAppTheme <T>(this BindableObject self, BindableProperty targetProperty, T light, T dark) => self.SetBinding(targetProperty, new AppThemeBinding { Light = light, Dark = dark });