This is a migrated thread and some comments may be shown as answers.

Selected tab not highlighted after updating viewmodel

1 Answer 62 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
stephen
Top achievements
Rank 1
stephen asked on 12 Sep 2011, 09:05 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 15 Sep 2011, 09:30 AM
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 >>

Tags
TabControl
Asked by
stephen
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or