Example #1
0
        /// <summary>
        /// Clears the old Children
        /// Creates the new View and adds it to the Children, and Invalidates the Layout
        /// </summary>
        /// <param name="newvalue"></param>
        private void ViewModelChangedImpl(T newvalue)
        {
            var newchild = TemplateSelector.ViewFor(newvalue);

            //Verify that newchild is a contentview
            Content = newchild;
            InvalidateLayout();
        }
        /// <summary>
        /// Select a datatemplate dynamically
        /// Prefer the TemplateSelector then the DataTemplate
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        protected virtual DataTemplate GetTemplateFor(Type type)
        {
            DataTemplate retTemplate = null;

            if (TemplateSelector != null)
            {
                retTemplate = TemplateSelector.TemplateFor(type);
            }
            return(retTemplate ?? ItemTemplate);
        }
Example #3
0
        /// <summary>
        /// Templates the selector changed.
        /// </summary>
        /// <param name="bo">The bo.</param>
        /// <param name="oldval">The oldval.</param>
        /// <param name="newval">The newval.</param>
        /// <exception cref="XLabs.Forms.Exceptions.InvalidBindableException"></exception>
        private static void TemplateSelectorChanged(BindableObject bo, TemplateSelector oldval, TemplateSelector newval)
        {
            var cv = bo as CarouselView <T>;

            if (cv == null)
            {
                throw new InvalidBindableException(bo, typeof(CarouselView <T>));
            }

            cv.SelectorChanged(newval);
        }
Example #4
0
        /// <summary>
        /// Clears the old Children
        /// Creates the new View and adds it to the Children, and Invalidates the Layout
        /// </summary>
        /// <param name="newvalue"></param>
        private void ViewModelChangedImpl(T newvalue)
        {
            View newChild = null;

            // check ItemTemplateSelector first
            if (currentItemSelector != null)
            {
                newChild = this.ViewFor(newvalue, currentItemSelector);
            }

            newChild = newChild ?? TemplateSelector.ViewFor(newvalue);
            //Verify that newchild is a contentview
            Content = newChild;
            InvalidateLayout(); // is this invalidate call necessary? modifying the content seems to do this already
        }