/// <summary>
        /// Called when [data template selector changed].
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="newValue">The new value.</param>
        /// <exception cref="System.ArgumentException">Cannot set both ItemTemplate and ItemTemplateSelector;ItemTemplateSelector</exception>
        protected virtual void OnDataTemplateSelectorChanged(DataTemplateSelector oldValue, DataTemplateSelector newValue)
        {
            // check to see we don't have an ItemTemplate set
            if (ItemTemplate != null && newValue != null)
            {
                throw new ArgumentException("Cannot set both ItemTemplate and ItemTemplateSelector", "ItemTemplateSelector");
            }

            currentItemSelector = newValue;
        }
Example #2
0
        /// <summary>
        /// Called when [data template selector changed].
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="newValue">The new value.</param>
        protected virtual void OnDataTemplateSelectorChanged(DataTemplateSelector oldValue, DataTemplateSelector newValue)
        {
            // Cache locally
            currentItemSelector = newValue;

            if (this.contentView != null)//may be constructing
            {
                this.contentView.ItemTemplateSelector = currentItemSelector;
            }
        }
Example #3
0
        /// <summary>
        /// Views for.
        /// </summary>
        /// <param name="This">The this.</param>
        /// <param name="item">The item.</param>
        /// <param name="selector">The selector.</param>
        /// <returns>View.</returns>
        /// <exception cref="System.InvalidOperationException">DataTemplate must be a View</exception>
        public static View ViewFor(this BindableObject This, object item, DataTemplateSelector selector)
        {
            if (selector != null)
            {
                var template = selector.SelectTemplate(item, This);
                if (template != null)
                {
                    var templateInstance = template.CreateContent();
                    // see if it's a view or a cell
                    var templateView = templateInstance as View;

                    if (templateView == null)
                    {
                        throw new InvalidOperationException("DataTemplate must be a View");
                    }

                    return(templateView);
                }
            }

            return(null);
        }
 private static void OnDataTemplateSelectorChanged(BindableObject bindable, DataTemplateSelector oldvalue, DataTemplateSelector newvalue)
 {
     ((RepeaterView <T>)bindable).OnDataTemplateSelectorChanged(oldvalue, newvalue);
 }
Example #5
0
 /// <summary>
 /// Called when [data template selector changed].
 /// </summary>
 /// <param name="oldValue">The old value.</param>
 /// <param name="newValue">The new value.</param>
 protected virtual void OnDataTemplateSelectorChanged(DataTemplateSelector oldValue, DataTemplateSelector newValue)
 {
     // cache value locally
     currentItemSelector = newValue;
 }
 /// <summary>
 /// Called when [data template selector changed].
 /// </summary>
 /// <param name="bindable">The bindable.</param>
 /// <param name="oldvalue">The oldvalue.</param>
 /// <param name="newvalue">The newvalue.</param>
 private static void OnDataTemplateSelectorChanged(BindableObject bindable, DataTemplateSelector oldvalue, DataTemplateSelector newvalue)
 {
     ((ExtendedListView)bindable).OnDataTemplateSelectorChanged(oldvalue, newvalue);
 }