Пример #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();
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        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);
        }