첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

■ ControlTemplate 엘리먼트 : 사각형 탭 헤더를 갖는 TabControl 엘리먼트 정의하기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip



MainWindow.xaml

 

 

<Window x:Class="TestProject.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="800"

    Height="600"

    Title="ControlTemplate 엘리먼트 : 사각형 탭 헤더를 갖는 TabControl 엘리먼트 정의하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Window.Resources>

        <Style TargetType="{x:Type TabItem}">

            <Setter Property="Background" Value="Transparent" />

            <Setter Property="Template">

                <Setter.Value>

                    <ControlTemplate TargetType="{x:Type TabItem}">

                        <Border x:Name="PART_Border"

                            Margin="2"

                            BorderBrush="LightGray"

                            BorderThickness="1"

                            Background="{TemplateBinding Background}">

                            <ContentPresenter

                                Margin="10 5 10 5"

                                ContentSource="Header" />

                        </Border>

                        <ControlTemplate.Triggers>

                            <Trigger Property="IsSelected" Value="True">

                                <Setter

                                    TargetName="PART_Border"

                                    Property="BorderBrush"

                                    Value="Black" />

                            </Trigger>

                        </ControlTemplate.Triggers>

                    </ControlTemplate>

                </Setter.Value>

            </Setter>

        </Style>    

    </Window.Resources>

    <Grid Margin="10">

        <TabControl>

            <TabItem Header="탭 헤더 1">

                <TextBlock

                    Margin="10"

                    Text="탭 헤더 1 내용 입니다." />

            </TabItem>

            <TabItem Header="탭 헤더 2">

                <TextBlock

                    Margin="10"

                    Text="탭 헤더 2 내용 입니다." />

            </TabItem>

            <TabItem Header="탭 헤더 3">

                <TextBlock

                    Margin="10"

                    Text="탭 헤더 3 내용 입니다." />

            </TabItem>

        </TabControl>

    </Grid>

</Window>

 

------------------------------------------------------------------------------------------------------------------------

728x90
반응형
Posted by 사용자 icodebroker
TAG , ,

댓글을 달아 주세요