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

RadTabControl no longer uses ContentTemplateSelector correctly

5 Answers 87 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Geoff Hardy
Top achievements
Rank 1
Geoff Hardy asked on 02 Mar 2010, 10:52 PM
We had a problem that with the RadGridView that occurred in with the 2009 Q3 build 1030 release. We downloaded the latest internal build (RadControls_for_Silverlight_2009_3_1426_Trial.zip) which did fix the problem but it introduced another problem with the RadTabControl.

We have a RadTabControl that looks like this:

        <Controls:RadTabControl Grid.Row="0" Grid.Column="2" ItemsSource="{Binding Workspaces}" SelectedItem="{Binding SelectedWorkspace, Mode=TwoWay}"
                                SelectedContentTemplateSelector="{StaticResource templateSelector}"
                                ContentTemplateSelector="{StaticResource templateSelector}">
            <Controls:RadTabControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <TextBlock Text="{Binding DisplayName}" FontSize="12" FontWeight="Bold" Margin="5"/>
                        <Button Click="CloseWorkspace"  Content="X" Cursor="Hand" IsTabStop="False" FontSize="8" Padding="0" Width="16" Height="16" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
                    </StackPanel>                           
                </DataTemplate>
            </Controls:RadTabControl.ItemTemplate>
        </Controls:RadTabControl>

The tab control uses a ContentTemplateSelector which is defined as :

 

public class DynamicDataTemplateSelector : DataTemplateSelector

 

{

 

public DataTemplate ManualDipReadEntryTemplate { get; set; }

 

 

public DataTemplate ScheduledFillTemplate { get; set; }

 

 

public override DataTemplate SelectTemplate(object item, DependencyObject container)

 

{

 

if (item is ManualDipReadViewModel)

 

{

 

return ManualDipReadEntryTemplate;

 

}

 

if (item is ScheduledFillViewModel)

 

{

 

return ScheduledFillTemplate;

 

}

 

return null;

 

}

}


The template selector is declared in App.xaml as:

            <!-- Templates -->
            <DataTemplate x:Key="manualDipReadTemplate">
                <View:ManualDipReadView/>
            </DataTemplate>
            <DataTemplate x:Key="scheduledFillTemplate">
                <View:ScheduledFillView/>
            </DataTemplate>
            <View:DynamicDataTemplateSelector x:Key="templateSelector"
                        ManualDipReadEntryTemplate="{StaticResource manualDipReadTemplate}"
                        ScheduledFillTemplate="{StaticResource scheduledFillTemplate}"/>

Although the DataContext for the tab control it appear to not use the ContentTemplateSelector until I click on the second tab item. Before that, the first tab just shows the string representation of the items in the Workspaces collection, and the selected tab is not highlighted, as it it could not figure out which tab was selected.

All this code works OK under build 1030, so this must have either been a bug introduced since that version or maybe the way the tab control works has changed?

5 Answers, 1 is accepted

Sort by
0
Geoff Hardy
Top achievements
Rank 1
answered on 03 Mar 2010, 04:37 PM
I have tried some other options and it turns out that the ContentTemplate property no longer works for RadTabControl. The problem appears to be that the control on the tab does not get loaded until you have clicked on a different tab. Then the OnLoaded event occurs. This is definitely a bug in this internal build of the RadTabControl.

To use this build I will have to abandon using RadTabControl and try using the Silverlight System.Windows.Controls.TabControl.
0
Miroslav
Telerik team
answered on 05 Mar 2010, 01:15 AM
Hi Geoff Hardy,

Yes, indeed this is a regression in the 14.26  build of the controls.

The issue was identified and now the TabControl works as before.

The official Q1 release is expected at the end of next week - of course  in it the TabControl will not have this regression.

Hopefully this timing will fit into your schedule.

Kind regards,
Miroslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Geoff Hardy
Top achievements
Rank 1
answered on 05 Mar 2010, 03:21 PM
Great - thanks!
0
nyi nyi
Top achievements
Rank 1
answered on 10 Apr 2010, 05:38 AM
Hi Miroslav,

I am facing the same issue. 
The fixed one has already released?

Regards,
Nyi Nyi
0
Valentin.Stoychev
Telerik team
answered on 12 Apr 2010, 02:59 PM
Hi nyi nyi,

Yes - this is fixed and released.

Regards,
Valentin.Stoychev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TabControl
Asked by
Geoff Hardy
Top achievements
Rank 1
Answers by
Geoff Hardy
Top achievements
Rank 1
Miroslav
Telerik team
nyi nyi
Top achievements
Rank 1
Valentin.Stoychev
Telerik team
Share this question
or