첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ Style 엘리먼트의 BasedOn 속성을 사용해 스타일을 상속하는 방법을 보여준다.

TestProject.zip
0.15MB

▶ MainPage.xaml

<?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>
        <Style x:Key="BastStyleKey" TargetType="View">
            <Setter Property="HorizontalOptions" Value="Center" />
            <Setter Property="VerticalOptions"   Value="Center" />
        </Style>
    </ContentPage.Resources>
    <StackLayout
        HorizontalOptions="Center"
        VerticalOptions="Center"
        Spacing="10">
        <StackLayout.Resources>
            <Style x:Key="LabelStyleKey" TargetType="Label" BasedOn="{StaticResource BastStyleKey}">
                <Setter Property="FontSize"       Value="18"     />
                <Setter Property="FontAttributes" Value="Italic" />
                <Setter Property="TextColor"      Value="Teal"   />
            </Style>
            <Style x:Key="ButtonStyleKey" TargetType="Button" BasedOn="{StaticResource BastStyleKey}">
                <Setter Property="BorderColor"  Value="Lime" />
                <Setter Property="CornerRadius" Value="5"    />
                <Setter Property="BorderWidth"  Value="5"    />
                <Setter Property="WidthRequest" Value="200"  />
                <Setter Property="TextColor"    Value="Teal" />
            </Style>
        </StackLayout.Resources>
        <Label
            Style="{StaticResource LabelStyleKey}"
            Text="This label uses style inheritance" />
        <Button
            Style="{StaticResource ButtonStyleKey}"
            Text="This button uses style inheritance" />
    </StackLayout>
</ContentPage>
728x90
그리드형(광고전용)
Posted by icodebroker
,