Selected tab not highlighted after updating viewmodel

2 posts, 1 answers
  1. stephen
    stephen avatar
    19 posts
    Member since:
    Jul 2010

    Posted 12 Sep 2011 Link to this post

    Hi,

    I have bound my RadTabControl to an observablecollection of TabItemViewModels, and I bind the currently selected tab to a property on my MainViewModel like this:

    <telerikG:RadTabControl ItemsSource="{Binding TabItems}" SelectedIndex="{Binding SelectedTabIndex, Mode=TwoWay}">
    where TabItems is a collection of TabItemViewModels, and SelectedTabIndex is an int property.

    I then use DataTemplates to populate my tabs like this:

    <telerikG:RadTabControl.ItemTemplate>
    <DataTemplate>
    blah blah blah
    </DataTemplate>
    </telerikG:RadTabControl.ItemTemplate>


    <telerikG:RadTabControl.ContentTemplate>
    <DataTemplate>
          blah blah blah
       </DataTemplate>
    </telerikG:RadTabControl.ContentTemplate>


    I then periodically update my TabItemViewModels collection that it is bound to - in fact i completely replace them by clearing the ObservableCollection of TabItemViewModels and creating a new one each time in my MainViewModel. The TabControl does remember which tab it was on each time i replace the collection, as it remains there, however, the tab heading that is selected is no longer highlighted.

    Can you see anything I am doing wrong?
    Manually setting the SelectedTabIndex property on my MainViewModel doesn't seem to work, I think because the SelectedTabIndex
     number doesnt change so the SelectedIndex event is not fired. 

    Even if I try to manually set it by firing these events and manually setting SelectedTabIndex in the .xaml.cs file, it doesnt make one of the tabs highlighted:
    SizeChanged="RadTabControl_SizeChanged" SelectionChanged="RadTabControl_SelectionChanged" LayoutUpdated="RadTabControl_LayoutUpdated" GotFocus="RadTabControl_GotFocus" 


    Thanks,
    Stephen
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 15 Sep 2011 Link to this post

    Hello Stephen,

     We are unable to reproduce this issue using the official Q2 2011 Dlls. Could you please check out our test project and let us know if we are missing something? Please also make sure that your ViewModels implement INotifyPropertyChanged interface which is mandatory.

    Kind regards,
    Petar Mladenov
    the Telerik team

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

  3. DevCraft banner
Back to Top