■ Style 클래스 : 암시적 스타일 사용하기

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


TestProject.zip


MainPage.xaml

 

 

<Page x:Class="TestProject.MainPage"

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

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

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Page.Resources>

        <x:String x:Key="StringKey">암시적 스타일</x:String>

        <Style TargetType="TextBlock">

            <Setter Property="FontFamily" Value="Times New Roman" />

            <Setter Property="FontSize"   Value="48"              />

            <Setter Property="Foreground">

                <Setter.Value>

                    <LinearGradientBrush>

                        <GradientStop Offset="0"    Color="Red"    />

                        <GradientStop Offset="0.17" Color="Orange" />

                        <GradientStop Offset="0.33" Color="Yellow" />

                        <GradientStop Offset="0.5"  Color="Green"  />

                        <GradientStop Offset="0.67" Color="Blue"   />

                        <GradientStop Offset="0.83" Color="Indigo" />

                        <GradientStop Offset="1"    Color="Violet" />

                    </LinearGradientBrush>

                </Setter.Value>

            </Setter>

        </Style>

    </Page.Resources>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <TextBlock

            HorizontalAlignment="Center"

            VerticalAlignment="Center"

            Foreground="{StaticResource ApplicationForegroundThemeBrush}"

            FontFamily="Portable User Interface"

            FontSize="48"

            Text="{StaticResource StringKey}" />

        <TextBlock

            HorizontalAlignment="Center"

            VerticalAlignment="Top"

            Text="Top Text" />

        <TextBlock

            HorizontalAlignment="Left"

            VerticalAlignment="Center"

            Text="Left Text" />

        <TextBlock

            HorizontalAlignment="Right"

            VerticalAlignment="Center"

            Text="Right Text" />

        <TextBlock

            HorizontalAlignment="Center"

            VerticalAlignment="Bottom"

            Text="Bottom Text" />

    </Grid>

</Page>

 

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요