RadTabControl no longer uses ContentTemplateSelector correctly

6 posts, 0 answers
  1. Geoff Hardy
    Geoff Hardy avatar
    58 posts
    Member since:
    Feb 2010

    Posted 02 Mar 2010 Link to this post

    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?
  2. Geoff Hardy
    Geoff Hardy avatar
    58 posts
    Member since:
    Feb 2010

    Posted 03 Mar 2010 Link to this post

    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.
  3. DevCraft banner
  4. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 04 Mar 2010 Link to this post

    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.
  5. Geoff Hardy
    Geoff Hardy avatar
    58 posts
    Member since:
    Feb 2010

    Posted 05 Mar 2010 Link to this post

    Great - thanks!
  6. nyi nyi
    nyi nyi avatar
    17 posts
    Member since:
    Apr 2010

    Posted 10 Apr 2010 Link to this post

    Hi Miroslav,

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

    Regards,
    Nyi Nyi
  7. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 12 Apr 2010 Link to this post

    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.
Back to Top
DevCraft banner