UniformItemsLayout
모든 UniformItemsLayout
행과 열의 크기가 같은 레이아웃입니다.
UniformItemsLayout 빌드
UniformItemsLayout
XAML 또는 C#에서 만들 수 있습니다.
XAML
XAML 네임스페이스 포함
XAML에서 도구 키트를 사용하려면 페이지 또는 보기에 다음 xmlns
을 추가해야 합니다.
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
따라서 다음을 수행합니다.
<ContentPage
x:Class="CommunityToolkit.Maui.Sample.Pages.MyPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
</ContentPage>
다음과 같이 포함 xmlns
하도록 수정됩니다.
<ContentPage
x:Class="CommunityToolkit.Maui.Sample.Pages.MyPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
</ContentPage>
UniformItemsLayout 사용
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="MyProject.MyContentPage">
<toolkit:UniformItemsLayout>
<BoxView BackgroundColor="Blue" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Yellow" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Red" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Black" HeightRequest="25" WidthRequest="25"/>
</toolkit:UniformItemsLayout>
</ContentPage>
C#
using CommunityToolkit.Maui.Views;
var page = new ContentPage
{
Content = new UniformItemsLayout
{
Children =
{
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Blue },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Yellow },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Red },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Black }
}
}
};
UniformItemsLayout 사용자 지정
열 UniformItemsLayout
과 행의 최대 수를 제한할 수 있습니다.
XAML
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="MyProject.MyContentPage">
<toolkit:UniformItemsLayout MaxRows="1" MaxColumns="1">
<BoxView BackgroundColor="Blue" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Yellow" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Red" HeightRequest="25" WidthRequest="25"/>
<BoxView BackgroundColor="Black" HeightRequest="25" WidthRequest="25"/>
</toolkit:UniformItemsLayout>
</ContentPage>
C#
using CommunityToolkit.Maui.Views;
var page = new ContentPage
{
Content = new UniformItemsLayout
{
MaxRows = 1,
MaxColumns = 1,
Children =
{
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Blue },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Yellow },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Red },
new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Colors.Black }
}
}
};
속성
속성 | Type | 설명 |
---|---|---|
MaxColumns |
int |
행의 최대 항목 수를 가져오거나 설정합니다. |
MaxRows |
int |
열의 최대 항목 수를 가져오거나 설정합니다. |
예제
.NET MAUI 커뮤니티 도구 키트 샘플 애플리케이션에서 작동 중인 이 기능의 예를 찾을 수 있습니다.
API
.NET MAUI 커뮤니티 도구 키트 GitHub 리포지토리에서 오버에 대한 UniformItemsLayout
소스 코드를 찾을 수 있습니다.
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET MAUI Community Toolkit
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기