Binding TabItems Visibility Property.

2 posts, 0 answers
  1. anester
    anester avatar
    1 posts
    Member since:
    Nov 2006

    Posted 17 Sep 2010 Link to this post

    I want to hide and display a tab based on a IsVisible property on a QTab that will be bound in the RadTab's ItemSource.

    Here are the classes I am using
    public class QTabs
        public ObservableCollection<QTab> Tabs { get; set; }
        public QTabs()
            Tabs = new ObservableCollection<QTab>
                    new QTab[] {
                        new QTab { Header="Header 1",Value="Value 1"},
                        new QTab { Header="Header 2",Value="Value 2"},
                        new QTab { Header="Header 3",Value="Value 3", IsVisible= Visibility.Collapsed},
                        new QTab { Header="Header 4",Value="Value 4"},
                        new QTab { Header="Header 5",Value="Value 5"}
    public class QTab
        public string Header { get; set; }
        public string Value { get; set; }
        public Visibility IsVisible { get; set; }
        public QTab()
            IsVisible = Visibility.Visible;

    public MainPage()
        AllTabs = new QTabs();
        DataContext = this;
    xaml snippets
    <my3:RadTabControl x:Name="tabscon" Grid.Row="1" DataContext="{Binding AllTabs}" ItemsSource="{Binding Tabs}">
            <Style TargetType="my3:RadTabItem">
                <Setter Property="HeaderTemplate">
                            <TextBlock Text="{Binding Header}"/>

    The above works so the binding is fine but when I add
    <Setter Property="Visibility" Value="{Binding IsVisible}"/>
    To the style I get an error that says I cannot set a readonly property.  Is there any way I can bind the the TabItems Visibility so I can dynamically had the tab.

  2. Viktor Tsvetkov
    Viktor Tsvetkov avatar
    382 posts

    Posted 20 Sep 2010 Link to this post

    Hi anester,

    In this case you can use ContainerBindings. Could you please examine the attached sample project and if you have further questions do not hesitate to ask?

    Best wishes,
    Viktor Tsvetkov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top