■ StaticResource 태그 확장을 사용해 리소스를 참조하는 방법을 보여준다.
▶ 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 |
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <ContentPage.Resources> <LayoutOptions x:Key="HorizontalOptionsKey" Alignment="Center" /> <LayoutOptions x:Key="VerticalOptionsKey" Alignment="Center" /> <x:Double x:Key="BorderWidthKey">3</x:Double> <x:Double x:Key="RotationAngleKey">-15</x:Double> <x:Double x:Key="FontSizeKey">24</x:Double> <OnPlatform x:Key="TextColorKey" x:TypeArguments="Color"> <On Platform="iOS" Value="Red" /> <On Platform="Android" Value="Aqua" /> <On Platform="UWP" Value="#80ff80" /> </OnPlatform> </ContentPage.Resources> <StackLayout HorizontalOptions="Center" VerticalOptions="Center"> <Button HorizontalOptions="{StaticResource HorizontalOptionsKey}" VerticalOptions="{StaticResource VerticalOptionsKey}" Rotation="{StaticResource RotationAngleKey}" BorderWidth="{StaticResource BorderWidthKey}" FontSize="{StaticResource FontSizeKey}" TextColor="{StaticResource TextColorKey}" Text="Do this!" /> <Button Margin="0,10,0,0" HorizontalOptions="{StaticResource HorizontalOptionsKey}" VerticalOptions="{StaticResource VerticalOptionsKey}" Rotation="{StaticResource RotationAngleKey}" BorderWidth="{StaticResource BorderWidthKey}" FontSize="{StaticResource FontSizeKey}" TextColor="{StaticResource TextColorKey}" Text="Do that!" /> <Button Margin="0,10,0,0" HorizontalOptions="{StaticResource HorizontalOptionsKey}" VerticalOptions="{StaticResource VerticalOptionsKey}" Rotation="{StaticResource RotationAngleKey}" BorderWidth="{StaticResource BorderWidthKey}" FontSize="{StaticResource FontSizeKey}" TextColor="{StaticResource TextColorKey}" Text="Do the other thing!" /> </StackLayout> </ContentPage> |