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

Nested tabcontrols problem

3 Answers 184 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
AshR
Top achievements
Rank 1
AshR asked on 07 Apr 2015, 01:20 PM

Hello,

I have a problem with a telerik radtabcontrol which doesn't occur with the standard wpf tabcontrol.

My code is structured as follows :-

<telerik:RadTabControl>
    <telerik:RadTabItem Header="Locations" IsSelected="True">
         
        // irrelevant stuff here
         
    </telerik:RadTabItem>
    <telerik:RadTabItem Header="Sources">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
 
            <telerik:RadTabControl  ItemsSource="{Binding MyViewModel.Sources}"
                                    SelectedItem="{Binding MyViewModel.SelectedSource}">
                <telerik:RadTabControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Style="{StaticResource SubTabTitle}" Text="{Binding DisplayName}"/>
                            <Button Command="{Binding Path=DataContext.MyViewModel.RemoveSourceCommand,ElementName=LayoutRoot}" CommandParameter="{Binding}" ToolTip="Remove Source" Style="{StaticResource RemoveButton}" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabControl.ItemTemplate>
                <telerik:RadTabControl.ContentTemplate>
                    <DataTemplate>
                        <ScrollViewer>
                            <StackPanel>
                                <view:EditExcelSourceControl ViewModel="{Binding Path=DataContext.MyViewModel, ElementName=LayoutRoot}" Workbook="{Binding Path=DataContext.MyViewModel.SelectedExcelWorkbook,ElementName=LayoutRoot}" Visibility="{Binding Path=DataContext.MyViewModel.HasSelectedExcelWorkbook,ElementName=LayoutRoot,Converter={c:BooleanToVisibilityConverter}}"/>
                                <view:EditTextSourceControl ViewModel="{Binding Path=DataContext.MyViewModel, ElementName=LayoutRoot}" File="{Binding Path=DataContext.MyViewModel.SelectedTextFile,ElementName=LayoutRoot}" Visibility="{Binding Path=DataContext.MyViewModel.HasSelectedTextFile,ElementName=LayoutRoot,Converter={c:BooleanToVisibilityConverter}}"/>
                            </StackPanel>
                        </ScrollViewer>
                    </DataTemplate>
                </telerik:RadTabControl.ContentTemplate>
            </telerik:RadTabControl>
        </Grid>
    </telerik:RadTabItem>
</telerik:RadTabControl>

Setting SelectedSource causes OnPropertyChange notifications for SelectedSource, and updates SelectedTextFile, SelectedExcelWorkbook, HasSelectedTextFile, HasSelectedExcelWorkbook as appropriate.

The user control has code as follows

<telerik:RadComboBox ItemsSource="{Binding DataContext.ViewModel.Points, ElementName=LayoutRoot}" SelectedValue="{Binding CurrentPoint}" Width="150">
    <telerik:RadComboBox.ItemTemplate>
        <ItemContainerTemplate>
            <TextBlock Text="{Binding Name}" Margin="0" Padding="0" />
        </ItemContainerTemplate>
    </telerik:RadComboBox.ItemTemplate>
</telerik:RadComboBox>

 

My problem is that if I switch between the toplevel tabcontrol items (from 'locations' tab to 'sources' tab), the object that the selectedsource is bound to on the nested tabcontrol will have it's currentpoint set to null.

If I modify the nested tabcontrol to be a simple WPF tabcontrol instead of a telerik:radtabcontrol, I do not have this problem where currentpoint is set to null.

Any help would be appreciated, thank you.

 

 

 

3 Answers, 1 is accepted

Sort by
0
AshR
Top achievements
Rank 1
answered on 08 Apr 2015, 02:54 PM
I have posted a support ticket on this issue.
0
Accepted
Petar Mladenov
Telerik team
answered on 09 Apr 2015, 06:37 AM
Hello AshR,

Could you please check out the following help article and let us know if setting IsContentPreserved = True works for you ? Thank you in advance.

RadTabControl How To Keep the Content State


Regards,
Petar Mladenov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
AshR
Top achievements
Rank 1
answered on 09 Apr 2015, 08:15 AM
Thank you Peter, that fixed the problem.
Tags
TabControl
Asked by
AshR
Top achievements
Rank 1
Answers by
AshR
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or