We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfTabControl and ItemsSource/Data binding

Thread ID:

Created:

Updated:

Platform:

Replies:

128055 Dec 28,2016 11:16 PM UTC Jan 2,2017 09:59 AM UTC UWP 2
loading
Tags: SfTabControl
Achint Mehta
Asked On December 28, 2016 11:16 PM UTC

I am trying to use data-binding for creating a SFTabControl on the MainPage using the code provided in one of the help pages of syncfusion for sftabcontrol (https://help.syncfusion.com/uwp/sftabcontrol/populating-items).
However, I am getting a blank page (and not tabs created)

Following is my code:

<Page
    x:Class="Man.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Man"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:syncfusion="using:Syncfusion.UI.Xaml.Grid"
    xmlns:navigation="using:Syncfusion.UI.Xaml.Controls.Navigation"    
    RequestedTheme="Dark"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>                
            </Grid.RowDefinitions>
            <navigation:SfTabControl Grid.Row="0" ItemsSource="{Binding Employees}"/>


    </Grid>
</Page>


namespace Man
{
    public class Employee 

    {

        public string Name { get; set; }

        public string Description { get; set; }

        
    }
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {

        private List<Employee> employees;

        public List<Employee> Employees

        {

            get { return employees; }

            set { employees = value; }

        }

        public MainPage()
        {
            this.InitializeComponent();

            Employees = new List<Employee>();

            Employees.Add(new Employee() { Name = "James", Description = "Description about James" });

            Employees.Add(new Employee() { Name = "Linda", Description = "Description about Linda" });

            Employees.Add(new Employee() { Name = "Carl", Description = "Description about Carl" });

            Employees.Add(new Employee() { Name = "Niko", Description = "Description about Niko" });

        }        
    }
}


Can anyone tell me whats wrong with the code. 

Also, I am not sure how this approach is supposed to work considering that there is no ObservableCollection implemented.

Is there a simpler working example for using ItemsSource/data-binding with SfTabControl

Achint Mehta
Replied On December 29, 2016 04:15 PM UTC

Apparently I figured out that replacing <navigation:SfTabControl Grid.Row="0" ItemsSource="{Binding Employees}"/> with <navigation:SfTabControl Grid.Row="0" ItemsSource="{x:Bind Employees, Mode=OneWay}"/> works to some extent.

Now if the Source List (Employees) is populated in the MainPage constructor then tabs are created but if Source List is populated in Loaded event of the page then there are not tabs created. This happens even if the Source List is defined as ObservableCollection

Marimuthu Sivalingam [Syncfusion]
Replied On January 2, 2017 09:59 AM UTC

Hi Achint,

Thank you for contacting Syncfusion support.

We suspect that you have missed to set DataContext, so that control could not get information about data source used in binding. We have prepared a sample to demonstrate creating SfTabControl items through binding and you can download it from the following link:

Sample: 128055_SfTabControlBinding

Regards,
Marimuthu S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;