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

TabItem Template

3 Answers 174 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 Jun 2017, 09:34 PM

I must be missing something simple. I'm just trying to work with the background colors for the TabItems. I've made a Control Template and Style. When I explore the Live Visual Tree, I find that BorderVisual is being defined from the default Implicit Styles file. Everything else above seems to be pulling correctly from the Style and Template I've made. What am I doing wrong?

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:telerik1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
                    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
                    xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls"
                    xmlns:telerikTabControl="clr-namespace:Telerik.Windows.Controls.TabControl;assembly=Telerik.Windows.Controls.Navigation"
                    xmlns:telerikNavigationPrimitives="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls.Navigation">
    <ControlTemplate x:Key="JobTypeTabItemTemplate" TargetType="{x:Type telerik:RadTabItem}">
        <Grid x:Name="wrapper">
            <Border x:Name="BorderVisual"
                    CornerRadius="3,3,0,0"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    Background="{TemplateBinding Background}"
                    BorderThickness="{TemplateBinding BorderThickness}"/>
            <telerikPrimitives:LayoutTransformControl x:Name="OrientationTransform">
                <ContentControl x:Name="HeaderElement"
                                IsTabStop="False"
                                Content="{TemplateBinding Header}"
                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                Foreground="{TemplateBinding HeaderForeground}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Margin="{TemplateBinding Padding}"
                                ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                SnapsToDevicePixels="True"/>
            </telerikPrimitives:LayoutTransformControl>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <!--<Setter TargetName="BorderVisual" Property="Background" Value="{telerik1:Office2016Resource ResourceKey=AccentMouseOverBrush}"/>
                            <Setter TargetName="BorderVisual" Property="BorderBrush" Value="{telerik1:Office2016Resource ResourceKey=AccentMouseOverBrush}"/>-->
                <Setter TargetName="BorderVisual" Property="Background" Value="{telerik1:Office2016Resource ResourceKey=AlternativeBrush}"/>
                <Setter TargetName="BorderVisual" Property="BorderBrush" Value="{telerik1:Office2016Resource ResourceKey=AlternativeBrush}"/>
                <Setter TargetName="HeaderElement" Property="Foreground" Value="{telerik1:Office2016Resource ResourceKey=MarkerBrush}"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <!--<Setter TargetName="BorderVisual" Property="Background" Value="{telerik1:Office2016Resource ResourceKey=AlternativeBrush}"/>
                            <Setter TargetName="BorderVisual" Property="BorderBrush" Value="{telerik1:Office2016Resource ResourceKey=AlternativeBrush}"/>-->
                <Setter TargetName="BorderVisual" Property="Background" Value="{telerik1:Office2016Resource ResourceKey=AccentMouseOverBrush}"/>
                <Setter TargetName="BorderVisual" Property="BorderBrush" Value="{telerik1:Office2016Resource ResourceKey=AccentMouseOverBrush}"/>
                <Setter TargetName="HeaderElement" Property="Foreground" Value="{telerik1:Office2016Resource ResourceKey=MarkerInvertedBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="JobTypeTabItemStyle" TargetType="{x:Type telerik:RadTabItem}" BasedOn="{StaticResource RadTabItemStyle}">
        <Setter Property="Template" Value="{StaticResource JobTypeTabItemTemplate}"/>
        <Setter Property="FontFamily" Value="{telerik1:Office2016Resource ResourceKey=FontFamily}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1 1 1 0"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="MinWidth" Value="5"/>
        <Setter Property="MinHeight" Value="5"/>
        <Setter Property="HeaderForeground" Value="{telerik1:Office2016Resource ResourceKey=MarkerInvertedBrush}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template" Value="{StaticResource TabItemTemplate}"/>
        <Setter Property="Padding" Value="18,6,18,3" />
        <Setter Property="Header" Value="{Binding TabText}"/>
        <Setter Property="FontSize" Value="14"/>
    </Style>
</ResourceDictionary>

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 15 Jun 2017, 02:24 PM
I should probably add that I'm trying to change the TabItem template for a databound TabControl. The above works just fine if I manually specify a template for a TabItem.
0
David
Top achievements
Rank 1
answered on 15 Jun 2017, 02:29 PM
Sigh...after fighting with this for 6 hours yesterday I found the problem - I specified the Template property twice in the TabItem style. Sorry to waste anyone's time. Feel free to delete this thread (as in, please delete this thread).
0
Stefan
Telerik team
answered on 19 Jun 2017, 05:53 AM
Hi David,

Thank you for the clarification and the effort to find the cause for the problem. We are glad that you have found a solution.

In case you need other assistance with our components, feel free to contact us again.

All the best,
Stefan X1
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TabControl
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or