Bind to TabItem IsSelected problems

2 posts, 1 answers
  1. Adiel
    Adiel avatar
    60 posts
    Member since:
    Jun 2012

    Posted 25 Apr 2010 Link to this post

    I have couple of tabs with ViewModel class for each.
    I want to bind the IsSelected DP to a property in the VM.
    Somehow the property not updated in the view model.

    I've create a demo project very simple and straightforward.

    The  xaml:

     <Grid x:Name="LayoutRoot" 
                <Controls:RadTabItem x:Name="tab1" 
                                     IsSelected="{Binding Tab1 }">  
                <Controls:RadTabItem Header="tab2" 
                                     IsSelected="{Binding Tab2}" /> 
            <StackPanel HorizontalAlignment="Right" 
                <TextBlock Text="{Binding AA}" /> 
                <Button x:Name="Select" 
                        Content="Select Tab 1" 
                        Click="Select_Click" /> 
                <Button x:Name="Select1" 
                        Content="Select Tab 2" 
                        Click="Select1_Click" /> 

    The code behinde:
     public partial class MainPage : UserControl  
            public MainPage()  
                ViewModel = new vm();  
            public vm ViewModel  
                get { return DataContext as vm; }  
                set { DataContext = value; }  
            private void Select_Click(object sender, RoutedEventArgs e)  
                ViewModel.Tab1 = true;  
            private void Select1_Click(object sender, RoutedEventArgs e)  
                ViewModel.Tab2 = true;  

    The view model:
     public class vm : INotifyPropertyChanged  
            private bool _tab1;  
            private bool _tab2;  
            public string AA  
                    return Tab1 ? "Tab1" : "Tab2";  
                set { OnPropChanged("AA"); }  
            public bool Tab1  
                get { return _tab1; }  
                    _tab1 = value;  
            public bool Tab2  
                get { return _tab2; }  
                    _tab2 = value;  
            private void OnPropChanged(string propName)  
                if (PropertyChanged != null)  
                    PropertyChanged(thisnew PropertyChangedEventArgs(propName));  
            #region INotifyPropertyChanged Members  
            public event PropertyChangedEventHandler PropertyChanged;

    Any ideas?
  2. Answer
    Vladislav avatar
    274 posts

    Posted 28 Apr 2010 Link to this post

    Hello Adiel,

    Can you please review the attached project?
    Basically I just added "Mode=TwoWay" in the binding expressions for "IsSelected" properties of the RadTabItems.

    Please, let us know if this solution works for you. 

    Kind regards,
    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 R3 2016 release webinar banner
Back to Top