Set Content of SFTabItem

Hi,

i'm new to android and syncfusion and try to add tab pages with linearlayout as content. 

I had a simple layout for testing:

            LinearLayout lay = new LinearLayout(this);
            lay.SetBackgroundColor(Color.LightSteelBlue);
            lay.AddView(new Button(this) { Text = "A" });
            lay.AddView(new Button(this) { Text = "A" });
            lay.AddView(new Button(this) { Text = "A" });

            SetContentView(lay);

I want to put this in Tabpages so i changed the code to

            tabView = new SfTabView(this);
            tabView.VisibleHeaderCount = 3;
            Color[] cols = new Color[] { Color.LightSteelBlue, Color.LightGreen, Color.LightYellow };
            for (int i = 0; i < 3; i++)
            {
                LinearLayout lay = new LinearLayout(this);
                lay.SetBackgroundColor(cols[i]);
                lay.AddView(new Button(this) { Text = string.Format("A{0}", i) });
                lay.AddView(new Button(this) { Text = string.Format("B{0}", i) });
                lay.AddView(new Button(this) { Text = string.Format("C{0}", i) });

                SfTabItem itm = new SfTabItem();
                itm.Title = "Test";
                itm.Content = lay;

                tabView.Items.Add(itm);                
            }
            SetContentView(tabView);

All i see is a blank page with the defined color - no buttons. I need a hint how to set the content of SFTabItem correctly, pls.


3 Replies

RK Rathana Kumar Sekar Syncfusion Team March 2, 2018 11:24 AM UTC

Hi Michael Roth,

Thanks for contacting Syncfusion Support.

We have checked the reported issue " SfTabView Item contents not appear" and we could reproduce from our side. We have logged issue report regard this and fix will be available our upcoming Volume 1 SP1 release, which will be rolled out by the end of this month.

Regards,
Rathanakumar S. 



PI piseysen August 2, 2019 02:54 AM UTC

How Can I add Content Page To SfTabItem content?


MK Muneesh Kumar G Syncfusion Team August 2, 2019 07:20 AM UTC

Hi Piseysen, 
 
Greetings from Syncfusion. 

We have validated your query, In our current implementation, we can only set Xamarin.Form.View as SfTabItem Content, so we don’t have support for load content  page as TabItem Content. We have already logged a feature report for this requirement and it can be tracked through our feature management system.   
  
 
To achieve your requirement, you can set content page content as tab item content. We have created a sample for this and please find the sample from below location. 
 
Sample Link: 
 
In this sample, we have added the following things. 
 
1.Created a view model with TabitemCollection  and also set content page content as tab item content as like below code snippet 
 
 public class ViewModel:INotifyPropertyChanged
    {
        private TabItemCollection items;
        public event PropertyChangedEventHandler PropertyChanged;
        public TabItemCollection Items
        {
            get { return items; }
            set { items = value; }
        }

        public ViewModel()
        {
            SetItems();

         }
          internal void SetItems()
        {
            Items = new TabItemCollection();
            TabViewItemPage1 page1 = new TabViewItemPage1();
            TabViewItemPage2 page2 = new TabViewItemPage2();
            TabViewItemPage3 page3 = new TabViewItemPage3();
            TabViewItemPage4 page4 = new TabViewItemPage4();
            Items.Add(new SfTabItem {  Content = page1.Content,  Title="Page1" });
            Items.Add(new SfTabItem {  Content = page2.Content,  Title="Page2" });
            Items.Add(new SfTabItem {  Content = page3.Content,  Title="Page3" });
            Items.Add(new SfTabItem {  Content = page4.Content,  Title="Page4" } );

        }

    }
 
 
2.Set the item collection to the SfTabView as like below code snippet 
  
 <tabView:SfTabView  Items="{Binding Items}" />   
 
Please get back us, if you have any concern. 
 
Thanks,    
Muneesh Kumar G.   
 


Loader.
Up arrow icon