Style TabItem : TabControl « Windows Presentation Foundation « C# / C Sharp






Style TabItem

Style TabItem
    

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="TabControlStyles.Page1">
  <Page.Resources>
    <Style TargetType="TabItem">
      <Setter Property="BorderThickness" Value="3"/>
      <Setter Property="BorderBrush" Value="Red"/>
      <Setter Property="Background" Value="LightBlue"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type TabItem}">
            <Border>
              <Grid>
                <Grid>
                  <Border CornerRadius="3,3,0,0" Background="{TemplateBinding Background}" 
                       BorderBrush="{TemplateBinding BorderBrush}" 
                       BorderThickness="{TemplateBinding BorderThickness}"/>
                </Grid>
                <Border BorderThickness="{TemplateBinding BorderThickness}" 
                     Padding="{TemplateBinding Padding}">
                  <ContentPresenter ContentSource="Header" 
                     HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                     VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Border>
              </Grid>
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

  </Page.Resources>


  <StackPanel Background="Ivory">
    <TextBlock FontSize="24">Styled Tab Control</TextBlock>
    <TabControl Width="250">
      <TabItem Header="One">
        <Ellipse Width="200" Height="200" Fill="#CABCAB"/>
      </TabItem>
      <TabItem Header="Two">
        <Ellipse Width="200" Height="200" Fill="#BADDF00D"/>
      </TabItem>
      <TabItem Header="Three">
        <Ellipse Width="200" Height="200" Fill="#654321"/>
      </TabItem>
      <TabItem Header="Four">
        <Ellipse Width="200" Height="200" Fill="#123456"/>
      </TabItem>
      <TabItem Header="Five">
        <Ellipse Width="200" Height="200" Fill="#F11001"/>
      </TabItem>
    </TabControl>
  </StackPanel>


</Page>

   
    
    
    
  








Related examples in the same category

1.Frame background, TabControl background
2.TabControl and Frame source
3.Style a TabControl using templates for the TabControl and TabItem elements.Style a TabControl using templates for the TabControl and TabItem elements.
4.TabItem HeaderTabItem Header
5.Tab page headersTab page headers
6.Put Different Objects to TabItemPut Different Objects to TabItem
7.Tab TestTab Test
8.Binds a TabControl to a collection of Employee objectsBinds a TabControl to a collection of Employee objects
9.Bind a TabControl to a data sourceBind a TabControl to a data source
10.Use a GroupBox control to create a container for a TabControl.Use a GroupBox control to create a container for a TabControl.