Esempio n. 1
0
        /// <summary>
        /// Generates views from data in collection.
        /// </summary>
        protected void CreateStaticTabItems()
        {
            if (ContentTemplates == null)
            {
                return;
            }

            foreach (var contentTemplate in ContentTemplates)
            {
                if (!typeof(Tab).IsAssignableFrom(contentTemplate.TemplateType))
                {
                    continue;
                }

                var templateData = new ContentTemplateData();
                var tab          = contentTemplate.Activator(templateData) as Tab;
                tab.IsDynamic = false; // because we don't want it destroyed when the view-switcher unloads it

                if (TabSwitchMode == SwitchMode.Enable)
                {
                    tab.IsActive = false;
                    tab.Load();
                }

                var tabHeader = CreateTabHeader(tab);
            }

            SelectedTabIndexChanged();
        }
Esempio n. 2
0
        /// <summary>
        /// Creates new item in collection.
        /// </summary>
        protected virtual View CreateItem(BindableObject item, Type templateType = null, string templateId = null)
        {
            var template = GetContentTemplate(templateType, templateId);

            var activator = template?.Activator;

            if (activator == null)
            {
                return(null);
            }

            var templateData = new ContentTemplateData {
                Item = item
            };
            var itemView = activator(templateData);

            return(itemView);
        }
Esempio n. 3
0
        /// <summary>
        /// Called before the view and its children has been loaded.
        /// </summary>
        protected override void BeforeLoad()
        {
            base.BeforeLoad();

            // generate expander content and header
            if (ContentTemplates == null)
            {
                return;
            }

            foreach (var contentTemplate in ContentTemplates)
            {
                if (typeof(ExpanderContent).IsAssignableFrom(contentTemplate.TemplateType))
                {
                    var templateData = new ContentTemplateData();
                    _expanderContent = contentTemplate.Activator(templateData) as ExpanderContent;
                }
                else if (typeof(ExpanderHeader).IsAssignableFrom(contentTemplate.TemplateType))
                {
                    var templateData = new ContentTemplateData();
                    _expanderHeader = contentTemplate.Activator(templateData) as ExpanderHeader;
                }
            }

            if (_expanderHeader == null)
            {
                _expanderHeader = new DefaultExpanderHeader(this);
            }

            _expanderHeader.Alignment = HeaderAlignment;
            if (HeaderHeight != null)
            {
                _expanderHeader.Height = HeaderHeight;
            }
            _expanderHeader.ParentExpander = this;
            _expanderHeader.Text           = Text;
            _expanderHeader.Sprite         = Sprite;

            if (_expanderContent != null)
            {
                _expanderContent.Margin = ContentMargin;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Sets content template data.
 /// </summary>
 public override void SetContentTemplateData(ContentTemplateData contentTemplateData)
 {
     ContentTemplateData = contentTemplateData;
 }
Esempio n. 5
0
 /// <summary>
 /// Sets content template data.
 /// </summary>
 public virtual void SetContentTemplateData(ContentTemplateData contentTemplateData)
 {
 }