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
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