Exemple #1
0
        /// <summary>
        /// Creates tab header for tab.
        /// </summary>
        protected View CreateTabHeader(Tab tab, BindableObject item = null)
        {
            var tabHeader = CreateItem(item, typeof(TabHeader), tab.TabHeaderId) as TabHeader;

            if (tabHeader == null)
            {
                // create default tab header
                tabHeader = new TabHeader(this, TabHeaderGroup);
            }

            if (item != null)
            {
                if (!_tabHeaders.ContainsKey(item))
                {
                    _tabHeaders.Add(item, tabHeader);
                }
            }

            tabHeader.ParentTabPanel = this;
            tabHeader.MoveTo(TabHeaderGroup);
            tabHeader.TabIndex = TabHeaderGroup.LayoutChildren.Count - 1;
            tabHeader.Load();

            // set default tab header text if undefined
            if (!Tab.TextProperty.IsUndefined(tab) && TabHeader.TextProperty.IsUndefined(tabHeader.Label))
            {
                tabHeader.Text = tab.Text;
            }

            if (TabHeaderWidth != null)
            {
                tabHeader.Width = TabHeaderWidth;
            }

            if (TabHeaderHeight != null)
            {
                tabHeader.Height = TabHeaderHeight;
            }

            return(tabHeader);
        }
        public TabPanelExample(View parent, View layoutParent = null, string id = null, Template template = null, Action <View> initializer = null) :
            base(parent, layoutParent, id, template ?? TabPanelExampleTemplates.Default, initializer)
        {
            // constructing TabPanel (TabPanel1)
            TabPanel1 = new TabPanel(this, this, "TabPanel1", TabPanel1Template);

            // binding <TabPanel Items="{player in @Players}">
            Bindings.Add(new Binding(new List <BindingPath> {
                new BindingPath(new List <string> {
                }, new List <Func <BindableObject> > {
                })
            }, new BindingPath(new List <string> {
                "TabPanel1", "Items"
            }, new List <Func <BindableObject> > {
                () => this, () => TabPanel1
            }), () => TabPanel1.Items = Models.Players, () => { }, false));

            // templates for TabPanel1
            TabPanel1.ContentTemplates.Add(new ContentTemplate(tiPlayer =>
            {
                var tabHeader1 = new TabHeader(this, TabPanel1.Content, "TabHeader1", TabHeader1Template);

                // binding <TabHeader Text="{player.Name}">
                tabHeader1.Bindings.Add(new Binding(new List <BindingPath> {
                    new BindingPath(new List <string> {
                        "Item", "Name"
                    }, new List <Func <BindableObject> > {
                        () => tiPlayer, () => (tiPlayer.Item as Delight.Player)
                    })
                }, new BindingPath(new List <string> {
                    "Text"
                }, new List <Func <BindableObject> > {
                    () => tabHeader1
                }), () => tabHeader1.Text = (tiPlayer.Item as Delight.Player).Name, () => { }, false));
                tabHeader1.IsDynamic      = true;
                tabHeader1.SetContentTemplateData(tiPlayer);
                return(tabHeader1);
            }, typeof(TabHeader), "TabHeader1"));

            // templates for TabPanel1
            TabPanel1.ContentTemplates.Add(new ContentTemplate(tiPlayer =>
            {
                var tab1   = new Tab(this, TabPanel1.Content, "Tab1", Tab1Template);
                var label1 = new Label(this, tab1.Content, "Label1", Label1Template);

                // binding <Label Text="{player.Name}">
                tab1.Bindings.Add(new Binding(new List <BindingPath> {
                    new BindingPath(new List <string> {
                        "Item", "Name"
                    }, new List <Func <BindableObject> > {
                        () => tiPlayer, () => (tiPlayer.Item as Delight.Player)
                    })
                }, new BindingPath(new List <string> {
                    "Text"
                }, new List <Func <BindableObject> > {
                    () => label1
                }), () => label1.Text = (tiPlayer.Item as Delight.Player).Name, () => { }, false));
                tab1.IsDynamic        = true;
                tab1.SetContentTemplateData(tiPlayer);
                return(tab1);
            }, typeof(Tab), "Tab1"));
            this.AfterInitializeInternal();
        }