TabItem Template

4 posts, 0 answers
  1. David
    David avatar
    32 posts
    Member since:
    Nov 2015

    Posted 14 Jun Link to this post

    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>
  2. David
    David avatar
    32 posts
    Member since:
    Nov 2015

    Posted 15 Jun Link to this post

    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.
  3. David
    David avatar
    32 posts
    Member since:
    Nov 2015

    Posted 15 Jun Link to this post

    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).
  4. Stefan
    Admin
    Stefan avatar
    771 posts

    Posted 19 Jun Link to this post

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