RadTabControl SelectedItem Binding Problem

2 posts, 0 answers
  1. Kevin Marois
    Kevin Marois avatar
    16 posts
    Member since:
    May 2010

    Posted 30 Jan 2012 Link to this post

    I am populating a RadTabControl in the code-behind, and it's bound to a property called SelectedBottomTab.

    Here's the XAML
    <telerik:RadTabControl x:Name="tabBottomTabPanel"
                            ItemsSource="{Binding BottomTabs}" 
                            SelectedItem="{Binding SelectedBottomTab}">

    then in the code behin I create the tabs:

    private ObservableCollection<RadTabItem> _BottomTabs;
    public ObservableCollection<RadTabItem> BottomTabs
        get { return _BottomTabs; }
            if (_BottomTabs != value)
                _BottomTabs = value;
    private RadTabItem _SelectedBottomTab = null;
    public RadTabItem SelectedBottomTab
        get { return _SelectedBottomTab; }
            if (_SelectedBottomTab != value)
                _SelectedBottomTab = value;

    private void setupBottomTabs()
        RadTabItem tabA = new RadTabItem { Header = "Tab A" };
        RadTabItem tabB = new RadTabItem { Header = "Tab B" };
        RadTabItem tabC = new RadTabItem { Header = "Tab C" };
        BottomTabs = new ObservableCollection<RadTabItem>();

    When change tabs the SelectedBottomTab property set it not firing.

  2. Petar Mladenov
    Petar Mladenov avatar
    3154 posts

    Posted 02 Feb 2012 Link to this post

    Hello Kevin Marois ,

    The setter does not fire because you haven't set TwoWay Binding in XAML:
    SelectedItem="{Binding SelectedBottomTab, Mode=TwoWay}"

    However, using a UiElements (RadTabItems) as a ViewModels is bad by design and may lead to various issues. Actually, when you bind the RadTabControl to collection of business objects, the RadTabItems are automatically created and you only define how they will look by ItemTemplate. I re-factored your solution accordingly. Please check it out and let us know if it satisfies you.

    Petar Mladenov
    the Telerik team

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

Back to Top