Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 950211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:31:46+00:00 2026-05-15T23:31:46+00:00

I would like to build a TabControl in Silverlight which is driven by a

  • 0

I would like to build a TabControl in Silverlight which is driven by a collection of objects. I’ll show the code below of a VERY basic setup that I’m trying to prototype.

MainPage.xaml

<UserControl x:Class="DataDrivenTabControl.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:local="clr-namespace:DataDrivenTabControl"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<UserControl.DataContext>
    <local:MainPage_ViewModel/>
</UserControl.DataContext>

<StackPanel>
    <controls:TabControl>
        <!-- What do I need to do here for a Template? -->
    </controls:TabControl>
</StackPanel>

MainPage_ViewModel.cs

public class MainPage_ViewModel : Base_ViewModel
{
    public MainPage_ViewModel()
    {
        PopulateCollectionOfTabs();
    }

    public ObservableCollection<TabItem_DataViewModel> CollectionOfTabs
    {
        get { return collectionOfTabs; }
        set
        {
            if (collectionOfTabs != value)
            {
                collectionOfTabs = value;
                OnPropertyChanged("CollectionOfTabs");
            }
        }
    }
    private ObservableCollection<TabItem_DataViewModel> collectionOfTabs = new ObservableCollection<TabItem_DataViewModel>();

    private void PopulateCollectionOfTabs()
    {
        this.CollectionOfTabs.Add(
            new TabItem_DataViewModel()
            {
                TabDescription = "Tab 1",
                ButtonDescription = "Button for Tab 1"
            });

        this.CollectionOfTabs.Add(
            new TabItem_DataViewModel()
            {
                TabDescription = "Tab 2",
                ButtonDescription = "Button for Tab 2"
            });
    }
}

TabItem_DataViewModel.cs

public class TabItem_DataViewModel : Base_ViewModel
{
    public string TabDescription
    {
        get { return tabDescription; }
        set
        {
            if (tabDescription != value)
            {
                tabDescription = value;
                OnPropertyChanged("TabDescription");
            }
        }
    }
    private string tabDescription = string.Empty;

    public string ButtonDescription
    {
        get { return buttonDescription; }
        set
        {
            if (buttonDescription != value)
            {
                buttonDescription = value;
                OnPropertyChanged("ButtonDescription");
            }
        }
    }
    private string buttonDescription = string.Empty;
}

All I’m really trying to do in this example is to get the TabControl to show up with a dynamic list of tabs which would be bound to a collection (“Tab 1” & “Tab 2” in the header for the current implementation). When you click on a Tab, there could be a button (for simplicity), where the content of the button would bind to ButtonDescription on the TabItem_DataViewModel. This is very basic, but if I can get this to work, I’ll for sure be able to implement the rest of my solution.

I’m sure this has to be done with templates on the TabControl, but I just left it empty hoping that someone would be able to point me in the right direction.

Any help will be greatly appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:31:47+00:00Added an answer on May 15, 2026 at 11:31 pm

    I was able to get it to work as expected by using Telerik’s RadTabControl as shown below. I used Telerik’s version since the ItemSource is an IEnumerable, not a collection of TabItems.

    <telerikNavigation:RadTabControl ItemsSource="{Binding CollectionOfTabs}">
            <telerikNavigation:RadTabControl.ItemContainerStyle>
                <Style TargetType="telerikNavigation:RadTabItem">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding TabDescription}"/>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <Button Content="{Binding ButtonDescription}" Width="100" HorizontalAlignment="Center"/>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </telerikNavigation:RadTabControl.ItemContainerStyle>
        </telerikNavigation:RadTabControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.