Beispiel #1
0
        void RemoveBinding(BindableProperty property, BindablePropertyContext context)
        {
            context.Binding.Unapply();

            if (property.BindingChanging != null)
            {
                property.BindingChanging(this, context.Binding, null);
            }

            context.Binding = null;
        }
Beispiel #2
0
        internal void SetBinding(BindableProperty targetProperty, BindingBase binding, bool fromStyle)
        {
            if (targetProperty == null)
            {
                throw new ArgumentNullException("targetProperty");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding");
            }

            BindablePropertyContext context = null;

            if (fromStyle && (context = GetContext(targetProperty)) != null && (context.Attributes & BindableContextAttributes.IsDefaultValue) == 0 &&
                (context.Attributes & BindableContextAttributes.IsSetFromStyle) == 0)
            {
                return;
            }

            context = context ?? GetOrCreateContext(targetProperty);
            if (fromStyle)
            {
                context.Attributes |= BindableContextAttributes.IsSetFromStyle;
            }
            else
            {
                context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
            }

            if (context.Binding != null)
            {
                context.Binding.Unapply();
            }

            BindingBase oldBinding = context.Binding;

            context.Binding = binding;

            if (targetProperty.BindingChanging != null)
            {
                targetProperty.BindingChanging(this, oldBinding, binding);
            }

            binding.Apply(BindingContext, this, targetProperty);
        }