VisualStudio/WPF

[WPF] Window.Resources 사용법

usingsystem 2023. 1. 4. 16:15
728x90

Window.Resources 를 사용하여 오브젝트들의 기본 틀정의 해서 손쉽게 디자인을 적용할 수 있다. 

    <Window.Resources>
        <Style x:Key="testStyle">
            <Setter Property="Label.Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="0.3">
                        <GradientStop Color="#FF00A7FF" Offset="0.003"/>
                        <GradientStop Color="White" Offset="1"/>
                        <GradientStop Color="#FF23DC3F" Offset="0.508"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    
   <Label x:Name="label" Style="{StaticResource testStyle}" Content="Label" HorizontalAlignment="Left" Margin="88,30,0,0" Grid.Row="1" VerticalAlignment="Top"/>

 

728x90