Exemplo n.º 1
0
        internal override async void Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
        {
            var view = bindObj as Element;

            if (view == null)
            {
                throw new InvalidOperationException();
            }

            base.Apply(newContext, bindObj, targetProperty, fromBindingContextChanged);

            Element templatedParent = await TemplateUtilities.FindTemplatedParentAsync(view);

            ApplyInner(templatedParent, bindObj, targetProperty);
        }
Exemplo n.º 2
0
		static async void OnContentChanged(BindableObject bindable, object oldValue, object newValue)
		{
			var self = (ContentPresenter)bindable;

			var oldView = (View)oldValue;
			var newView = (View)newValue;
			if (oldView != null)
			{
				self.InternalChildren.Remove(oldView);
				oldView.ParentOverride = null;
			}

			if (newView != null)
			{
				self.InternalChildren.Add(newView);
				newView.ParentOverride = await TemplateUtilities.FindTemplatedParentAsync((Element)bindable);
			}
		}
Exemplo n.º 3
0
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
        async void ApplyRelativeSourceBinding(
            BindableObject targetObject,
            BindableProperty targetProperty)
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
        {
            if (!(Source is RelativeBindingSource relativeSource))
            {
                return;
            }

            var relativeSourceTarget = RelativeSourceTargetOverride ?? targetObject as Element;

            if (!(relativeSourceTarget is Element))
            {
                throw new InvalidOperationException();
            }

            object resolvedSource = null;

            switch (relativeSource.Mode)
            {
            case RelativeBindingSourceMode.Self:
                resolvedSource = relativeSourceTarget;
                break;

            case RelativeBindingSourceMode.TemplatedParent:
                resolvedSource = await TemplateUtilities.FindTemplatedParentAsync(relativeSourceTarget);

                break;

            case RelativeBindingSourceMode.FindAncestor:
            case RelativeBindingSourceMode.FindAncestorBindingContext:
                ApplyAncestorTypeBinding(targetObject, relativeSourceTarget, targetProperty);
                return;

            default:
                throw new InvalidOperationException();
            }

            _expression.Apply(resolvedSource, targetObject, targetProperty);
        }
Exemplo n.º 4
0
 protected object GetTemplateChild(string name) => TemplateUtilities.GetTemplateChild(this, name);
Exemplo n.º 5
0
 protected override void OnChildRemoved(Element child, int oldLogicalIndex)
 {
     base.OnChildRemoved(child, oldLogicalIndex);
     TemplateUtilities.OnChildRemoved(this, child);
 }