This is a migrated thread and some comments may be shown as answers.

How can i achieve Dynamicaly RadTabView

1 Answer 256 Views
TabView
This is a migrated thread and some comments may be shown as answers.
Pramod
Top achievements
Rank 1
Pramod asked on 01 Mar 2018, 11:02 AM

Hi Team,

How can I achieve RadTabView Dynamically In Xamarin forms

If I am going to created One Tabview then that Tabview  will be used as dynamic , and I m going to pass array or list for that One tabbed

that time it will increase  TabView pages

Please help.

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 01 Mar 2018, 06:08 PM
Hello Pramod,

If I understand what you're trying to say correctly, you're looking to dynamically add or remove TabViewItems at runtime? This can be done by adding or removing items from the TabView's Items property.

Here's an example:

<telerikPrimitives:RadTabView x:Name="tabView"/>

tabView.Items.Add(new TabViewItem {HeaderText = "Added Tab"});


If you're asking if there is an MVVM type of property, like "ItemsSource", that is not supported at this time. You can submit a feature request here in the Feedback Portal.

In the meantime, if you do have an ObservableCollection that you'd like to keep in sync with the TabView, you can hook into the CollectionChanged event and update the TabView there.

For example:

private ObservableCollection<TabViewItem> MyTabsSource { get; set; } = new ObservableCollection<TabViewItem>();
 
public MyPage()
{
    InitializeComponent();
 
    MyTabsSource.CollectionChanged += MyTabsSource_CollectionChanged;
}
 
private void MyTabsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
    if (e.NewItems != null && e.NewItems.Count > 0)
    {
        foreach (var item in e.NewItems)
        {
            tabView.Items.Add(item as TabViewItem);
        }
    }
 
    if (e.OldItems != null && e.OldItems.Count > 0)
    {
        foreach (var item in e.OldItems)
        {
            tabView.Items.Remove(item as TabViewItem);
        }
    }
}


If you have any difficulty using TabView Items.Add or Items.Remove, open a support ticket here and attach your code so that we can investigate further.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TabView
Asked by
Pramod
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or