Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > How to disable tabs on a bound collection

Not answered How to disable tabs on a bound collection

Feed from this thread
  • Asela avatar

    Posted on Oct 7, 2011 (permalink)

    Hi there,

    I have a dynamic collection which I bind to the tab control, however, I would also like to be able to enable / disable the tabs based on some criteria, however, I am unsure of what to  bind to so I Can disable tabbing to the control.

    I followed your basic demo for binding to a collection please see code below

    <Grid>
            <Grid.DataContext>
                <WpfApplication3:MainWindowViewModel/>
            </Grid.DataContext>
            <telerik:RadTabControl ItemsSource="{Binding People}" >
                <telerik:RadTabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}"/>
                    </DataTemplate>
                   
                </telerik:RadTabControl.ItemTemplate>
                <telerik:RadTabControl.ContentTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Age}"/>
                    </DataTemplate>
                </telerik:RadTabControl.ContentTemplate>
            </telerik:RadTabControl>
        </Grid>

    Thanks

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Oct 11, 2011 (permalink)

    Hi Asela,

     Supposing you are following the approach demonstrated in this help article, you can introduce boolean property in the Person class:

    public class Person
     {
         public Person(string name, int age)
         {
             this.Name = name;
             this.Age = age;
         }
         public string Name
         {
             get;
             set;
         }
         public int Age
         {
             get;
             set;
         }
     
         public bool Enabled { get; set; }
     }
    and bind it to the IsEnabled property of the corresponding RadTabItems via StyleBindings:
    <Grid.Resources>     
               <local:ViewModel x:Key="DataSource" />
                
               <Style TargetType="telerik:RadTabItem">
                   <Setter Property="IsEnabled" Value="{Binding Enabled, Mode=TwoWay}" />
               </Style>
     
               <DataTemplate x:Key="ContentTemplate">
                   <Grid>
                       <TextBlock Text="{Binding Age}" />
                   </Grid>
               </DataTemplate>
     
               </Grid.Resources>
    You can find this realized in the attached solution. Please let us know if this is what you need. Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > How to disable tabs on a bound collection
Related resources for "How to disable tabs on a bound collection"

WPF TabControl Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]