■ Style 엘리먼트 사용하기

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

<StackPanel

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

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

    <StackPanel.Resources>

        <Style x:Key="ButtonStyleKey">

            <Style.Resources>

                <LinearGradientBrush

                    x:Key="LinearGradientBrushKey"

                    StartPoint="1 0"

                    EndPoint="1 1">

                    <LinearGradientBrush.GradientStops>

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

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

                    </LinearGradientBrush.GradientStops>

                </LinearGradientBrush>

            </Style.Resources>

            <Setter Property="Control.FontSize"            Value="24"                                      />

            <Setter Property="Control.HorizontalAlignment" Value="Center"                                  />

            <Setter Property="Control.Margin"              Value="24"                                      />

            <Setter Property="Control.Background"          Value="{StaticResource LinearGradientBrushKey}" />

        </Style>

    </StackPanel.Resources>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 1</Button>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 2</Button>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 3</Button>

</StackPanel>

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

Posted by 사용자 icodebroker
TAG