Hi Mark,
Greetings from Syncfusion.
Query : Can the tab control bind to a collection of templates with a Template property in the same way the rotator does? How can you bind unique pages (each page is different ) to the tab control?
In our current implementation, we can only set Xamarin.Form.View as SfTabItem Content, so we don’t have support for load 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 { private TabItemCollection items;
public TabItemCollection Items { get { return items; } set { items = value; } }
public ViewModel() {
Items = new TabItemCollection(); SetItems();
} internal void SetItems() { TabViewItemPage1 page1 = new TabViewItemPage1(); TabViewItemPage2 page2 = new TabViewItemPage2(); TabViewItemPage3 page3 = new TabViewItemPage3(); TabViewItemPage4 page4 = new TabViewItemPage4(); Items.Add(new SfTabItem { Title = "Page1", Content = page1.Content }); Items.Add(new SfTabItem { Title = "Page2", Content = page2.Content }); Items.Add(new SfTabItem { Title = "Page3", Content = page3.Content }); Items.Add(new SfTabItem { Title = "Page4", Content = page4.Content });
}
} |
2.Set the item collection to the SfTabView as like below code snippet
<ContentPage.BindingContext> <local:ViewModel/> </ContentPage.BindingContext> <StackLayout> <tabView:SfTabView x:Name="tabview" Items="{Binding Items}" VerticalOptions="FillAndExpand"> </tabView:SfTabView> </StackLayout> |
Please get back us, if you have any concern.
Regards,
Muneesh Kumar G