Silverlight TabControl样式

View Code
<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="SilverlightApplication1.UserControl1"
     xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
     xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
              xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    d:DesignWidth="640" d:DesignHeight="480" Background="#FF5DB0C6">

<UserControl.Resources>
        <DropShadowEffect x:Key="Drop_shadow_text"
                    BlurRadius="5" 
                    ShadowDepth="2" 
                    Color="Black"
                    Opacity="0.8" 
                    Direction="315">
        </DropShadowEffect>
        <DropShadowEffect x:Key="Drop_shadow_bottom"
                    BlurRadius="5" 
                    ShadowDepth="2" 
                    Opacity="0.4" 
                    Direction="275">
        </DropShadowEffect>
        <LinearGradientBrush x:Key="Gradient_darkblue_Back"
                  EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#00B3F2" Offset="0" />
            <GradientStop Color="#0092CA" Offset="1" />
        </LinearGradientBrush>
        <ControlTemplate x:Key="CloseBtnTemplate" TargetType="Button">
            <Grid>
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="CloseBtnFocusStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="close" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.8"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Normal">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="close" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.2"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Button x:Name="close" Cursor="Hand" Height="14" HorizontalAlignment="Left" Tag="{TemplateBinding Tag}" VerticalAlignment="Top" Width="14" AllowDrop="False" UseLayoutRounding="True" Margin="0,7,0,0" Padding="0" Background="Transparent" BorderThickness="0">
                    <Button.Content>
                        <Image Source="/SilverlightApplication2;component/images/CloseButton.png" Height="14" Width="14" />
                    </Button.Content>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <i:InvokeCommandAction Command="{Binding CloseTabCommand}" CommandParameter="{Binding Tag, ElementName=close, Mode=OneWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </Grid>
        </ControlTemplate>
        <ControlTemplate x:Key="CustomTabItemTemplate" TargetType="sdk:TabItem">
            <Grid Width="Auto" Height="Auto" x:Name="TabItemRoot" Margin="4,0,2,0">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="CommonStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="0" />
                            <vsm:VisualTransition To="MouseOver" GeneratedDuration="0:0:0.1" />
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Normal" />
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="FocusVisualTop" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="0" Value="0.3" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Disabled"/>
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="FocusStates">
                        <vsm:VisualState x:Name="Focused" />
                        <vsm:VisualState x:Name="Unfocused" />
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="SelectionStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Selected" >
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Unselected" >
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="textBlock" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="textBlock1" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border3" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Grid x:Name="TemplateBottomSelected" Canvas.ZIndex="1">
                    <Border BorderThickness="0" Background="Transparent" Margin="-2,2,-2,0" CornerRadius="7,7,0,0">
                        <Border x:Name="borderw" BorderThickness="0" Background="Transparent">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="18" />
                                </Grid.ColumnDefinitions>
                                <Border Grid.Column="0" x:Name="border" Background="White" CornerRadius="4,0,0,0" Margin="0,0,0,-1"/>
                                <Border Grid.Column="1" x:Name="border2" Background="White" CornerRadius="0,4,0,0" Margin="0,0,0,-1" />
                                <Border Grid.Column="1" x:Name="border3" Background="Transparent" Margin="0,0,0,-1" Opacity="0"/>
                                <TextBlock Grid.Column="0" Grid.ColumnSpan="2" x:Name="textBlock" Text="{TemplateBinding Header}" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Trebuchet MS" FontSize="14" Foreground="Black" Margin="5,7,5,5" Cursor="Hand" IsHitTestVisible="True" />
                                <TextBlock Grid.Column="0" Grid.ColumnSpan="2" x:Name="textBlock1" Text="{TemplateBinding Header}" HorizontalAlignment="Left" Margin="5,7,5,5" FontSize="14" VerticalAlignment="Center" FontFamily="Trebuchet MS" Foreground="#FFDDDDDD" Visibility="Visible" Opacity="0" Cursor="Hand" />
                            </Grid>
                        </Border>
                    </Border>
                    <Border x:Name="FocusVisualTop" CornerRadius="4,4,0,0" BorderBrush="White" Background="Transparent" BorderThickness="1,1,1,0" Margin="-2,2,-2,0" Opacity="0" IsHitTestVisible="false" />
                </Grid>
            </Grid>
        </ControlTemplate>
        <Style x:Key="tabItemStyle" TargetType="sdk:TabItem">
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Padding" Value="6,2,6,2"/>
            <Setter Property="Background" Value="#FF1F3B53" />
            <Setter Property="BorderBrush" Value="#FFA3AEB9" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="MinWidth" Value="5" />
            <Setter Property="MinHeight" Value="5" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="MinWidth" Value="5"/>
            <Setter Property="MinHeight" Value="5"/>
            <Setter Property="Template" Value="{StaticResource CustomTabItemTemplate}" />
            <Setter Property="FontFamily" Value="Trebuchet MS"/>
        </Style>
        <Style x:Key="tabStyle"  TargetType="sdk:TabControl">
            <Setter Property="Background" Value="{x:Null}"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sdk:TabControl">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" Width="Auto" CornerRadius="7,7,0,0" Background="{StaticResource Gradient_darkblue_Back}" Effect="{StaticResource Drop_shadow_bottom}" BorderThickness="0,0,0,1" BorderBrush="#FF666666" AllowDrop="False">
                                <Primitives:TabPanel HorizontalAlignment="Left" x:Name="TabPanelTop" VerticalAlignment="Center" Canvas.ZIndex="1" Opacity="1"/>
                            </Border>
                            <!--<ContentControl Margin="5,4,5,5" Grid.Row="1" prism:RegionManager.RegionName="ModuleContentRegion"/>-->
                            <Grid Width="Auto" Grid.Row="1" x:Name="ContentGrid">
                                <ContentPresenter Cursor="{TemplateBinding Cursor}" x:Name="ContentTop" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Opacity="1"/>
                                <ContentControl x:Name="TabContentView" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Opacity="1" />
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <sdk:TabControl  Style="{StaticResource tabStyle}"  Height="224" HorizontalAlignment="Left" Margin="12,64,0,0" Name="tabControl1" VerticalAlignment="Top" Width="634">
            <sdk:TabItem  Style="{StaticResource tabItemStyle}" Header="TabItem1" Name="tabItem1" Background="#FF1F3B53">
                <Grid Width="322">
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem Style="{StaticResource tabItemStyle}" Header="TabItem2" Name="tabItem2">
                <Grid Width="344">
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem IsSelected="True" Style="{StaticResource tabItemStyle}" Header="This is TabItem3" Name="tabItem3">
                <Grid >
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock3" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>        
    </Grid>
</UserControl>

View Code
<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="SilverlightApplication1.UserControl2"
     xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
     xmlns:Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
              xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    d:DesignWidth="640" d:DesignHeight="480" Background="#FF5DB0C6">

    <UserControl.Resources>

        <!--Start sdk:TabControl Style-->
        <DropShadowEffect x:Key="Drop_shadow_text"
                    BlurRadius="5" 
                    ShadowDepth="2" 
                    Color="Black"
                    Opacity="0.5" 
                    Direction="315">
        </DropShadowEffect>
        <DropShadowEffect x:Key="Drop_shadow_bottom"
                    BlurRadius="5" 
                    ShadowDepth="1" 
                    Opacity="0.4" 
                    Direction="275">
        </DropShadowEffect>

        <ControlTemplate x:Key="CustomTabItemTemplate" TargetType="sdk:TabItem">
            <Grid Width="Auto" Height="Auto" x:Name="TabItemRoot" Margin="4,0,2,0">
                <vsm:VisualStateManager.VisualStateGroups>
                    <vsm:VisualStateGroup x:Name="CommonStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="0" />
                            <vsm:VisualTransition To="MouseOver" GeneratedDuration="0:0:0.1" />
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Normal" >
                            <Storyboard>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="MouseOver">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="0" Duration="00:00:00.001" Storyboard.TargetName="FocusVisualTop" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="0" Value="0.3" />
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Disabled"/>
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="FocusStates">
                        <vsm:VisualState x:Name="Focused" />
                        <vsm:VisualState x:Name="Unfocused" />
                    </vsm:VisualStateGroup>
                    <vsm:VisualStateGroup x:Name="SelectionStates">
                        <vsm:VisualStateGroup.Transitions>
                            <vsm:VisualTransition GeneratedDuration="00:00:00.3000000"/>
                        </vsm:VisualStateGroup.Transitions>
                        <vsm:VisualState x:Name="Selected" >
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                        <vsm:VisualState x:Name="Unselected" >
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="textBlock" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>

                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="textBlock1" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border3" Storyboard.TargetProperty="(UIElement.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </vsm:VisualState>
                    </vsm:VisualStateGroup>
                </vsm:VisualStateManager.VisualStateGroups>
                <Grid x:Name="TemplateBottomSelected" Canvas.ZIndex="1">
                    <Border BorderThickness="0" Background="Transparent" Margin="-2,2,-2,0" CornerRadius="7,7,0,0">
                        <Border x:Name="borderw" BorderThickness="0" Background="Transparent">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Border Grid.Column="0" x:Name="border" Background="White" CornerRadius="4,0,0,0" Margin="0,0,0,-1"/>
                                <Border Grid.Column="1" x:Name="border2" Background="White" CornerRadius="0,4,0,0" Margin="0,0,0,-1" />
                                <Border Grid.Column="1" x:Name="border3" Background="Transparent" Margin="0,0,0,-1" Opacity="0"/>
                                <TextBlock Grid.Column="0" x:Name="textBlock" Text="{TemplateBinding Header}" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Trebuchet MS" FontSize="14" Foreground="Black" Margin="5,7,5,5" Cursor="Hand" IsHitTestVisible="True" />
                                <TextBlock Grid.Column="0" x:Name="textBlock1" Text="{TemplateBinding Header}" HorizontalAlignment="Center" Margin="5,7,5,5" FontSize="14" VerticalAlignment="Center" FontFamily="Trebuchet MS" Foreground="Gray" Visibility="Visible" Opacity="0" Cursor="Hand" />

                            </Grid>
                        </Border>
                    </Border>
                    <Border x:Name="FocusVisualTop" CornerRadius="0,0,0,0" BorderBrush="White" Background="Transparent" BorderThickness="1,1,1,0" Margin="-2,2,-2,0" Opacity="0" IsHitTestVisible="false" />
                </Grid>
            </Grid>
        </ControlTemplate>
        <Style x:Key="tabItemStyle" TargetType="sdk:TabItem">
            <Setter Property="IsTabStop" Value="False"/>
            <Setter Property="Padding" Value="6,2,6,2"/>
            <Setter Property="Background" Value="#FF1F3B53" />
            <Setter Property="BorderBrush" Value="#FFA3AEB9" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="MinWidth" Value="5" />
            <Setter Property="MinHeight" Value="5" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="MinWidth" Value="5"/>
            <Setter Property="MinHeight" Value="5"/>
            <Setter Property="Template" Value="{StaticResource CustomTabItemTemplate}" />
            <Setter Property="FontFamily" Value="Trebuchet MS"/>
        </Style>
        <Style x:Key="tabStyle"  TargetType="sdk:TabControl">
            <Setter Property="Background" Value="{x:Null}"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sdk:TabControl">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Border Grid.Row="0" Width="Auto" CornerRadius="0,0,0,0" Effect="{StaticResource Drop_shadow_bottom }" BorderThickness="0,0,0,1" BorderBrush="#FF666666" AllowDrop="False">
                                <Primitives:TabPanel HorizontalAlignment="Left" x:Name="TabPanelTop" VerticalAlignment="Center" Canvas.ZIndex="1" Opacity="1"/>
                            </Border>
                            <!--<ContentControl Margin="5,4,5,5" Grid.Row="1" prism:RegionManager.RegionName="ModuleContentRegion"/>-->
                            <Grid Width="Auto" Grid.Row="1" x:Name="ContentGrid">
                                <ContentPresenter Cursor="{TemplateBinding Cursor}" x:Name="ContentTop" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Opacity="1"/>
                                <ContentControl x:Name="TabContentView" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Opacity="1" />
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--End sdk:TabControl Style-->

    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <sdk:TabControl  Style="{StaticResource tabStyle}"  Height="224" HorizontalAlignment="Left" Margin="12,64,0,0" Name="tabControl1" VerticalAlignment="Top" Width="634">
            <sdk:TabItem  Style="{StaticResource tabItemStyle}" Header="TabItem1" Name="tabItem1" Background="#FF1F3B53">
                <Grid Width="322">
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem Style="{StaticResource tabItemStyle}" Header="TabItem2" Name="tabItem2">
                <Grid Width="344">
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
            <sdk:TabItem IsSelected="True" Style="{StaticResource tabItemStyle}" Header="This is TabItem3" Name="tabItem3">
                <Grid >
                    <TextBlock Height="53" HorizontalAlignment="Left" Margin="22,13,0,0" Name="textBlock3" Text="TextBlock" VerticalAlignment="Top" Width="147" />
                </Grid>
            </sdk:TabItem>
        </sdk:TabControl>

    </Grid>
</UserControl>
原文地址:https://www.cnblogs.com/mygod/p/2763581.html