[C#/UWP] x:Key 속성을 사용해 리소스 사용하기
■ x:Key 속성을 사용해 리소스를 사용하는 방법을 보여준다. ▶ MainPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<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> <LinearGradientBrush x:Key="RainbowBrushKey"> <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> <FontFamily x:Key="FontFamilyKey">Times New Roman</FontFamily> <x:Double x:Key="FontSizeKey">48</x:Double> </Page.Resources> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48" Text="{StaticResource StringKey}" /> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="{StaticResource RainbowBrushKey}" FontFamily="{StaticResource FontFamilyKey}" FontSize="{StaticResource FontSizeKey}" Text="Top Text" /> <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="{StaticResource RainbowBrushKey}" FontFamily="{StaticResource FontFamilyKey}" FontSize="{StaticResource FontSizeKey}" Text="Left Text" /> <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="{StaticResource RainbowBrushKey}" FontFamily="{StaticResource FontFamilyKey}" FontSize="{StaticResource FontSizeKey}" Text="Right Text" /> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="{StaticResource RainbowBrushKey}" FontFamily="{StaticResource FontFamilyKey}" FontSize="{StaticResource FontSizeKey}" Text="Bottom Text" /> </Grid> </Page> |
TestProject.zip