■ ContentPresenter 엘리먼트를 사용하는 방법을 보여준다.
▶ App.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 |
<?xml version = "1.0" encoding = "UTF-8" ?> <Application x:Class="TestProject.App" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <Application.Resources> <ControlTemplate x:Key="TealControlTemplateKey"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="0.1*" /> <RowDefinition Height="0.8*" /> <RowDefinition Height="0.1*" /> </Grid.RowDefinitions> <BoxView Color="Teal" /> <Label VerticalOptions="Center" Margin="20,0,0,0" FontSize="24" TextColor="White" Text="{TemplateBinding Title}" /> <ContentPresenter Grid.Row="1" /> <BoxView Grid.Row="2" Color="Teal" /> <Label Grid.Row="2" HorizontalOptions="Start" VerticalOptions="Center" Margin="20,0,0,0" TextColor="White" Text="테마 변경" /> <Label Grid.Row="2" VerticalOptions="Center" HorizontalOptions="End" Margin="0,0,20,0" TextColor="White" Text="도움말" /> </Grid> </ControlTemplate> </Application.Resources> </Application> |
▶ 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 |
<?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" ControlTemplate="{StaticResource TealControlTemplateKey}" Title="테스트 앱"> <StackLayout HorizontalOptions="Center" VerticalOptions="Center" Spacing="10"> <Entry HorizontalOptions="Center" Placeholder="사용자명을 입력해 주시기 바랍니다." /> <Entry HorizontalOptions="Center" Placeholder="패스워드를 입력해 주시기 바랍니다." IsPassword="True" /> <Button HorizontalOptions="Center" Text="로그인" /> </StackLayout> </ContentPage> |