728x90
반응형
728x170
▶ 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"
xmlns:local="clr-namespace:TestProject">
<ContentPage.Resources>
<local:ImageSourceConverter x:Key="ImageSourceConverterKey" />
</ContentPage.Resources>
<ListView x:Name="listView"
RowHeight="70"
SeparatorVisibility="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid
VerticalOptions="Center"
Padding="5"
RowDefinitions="Auto"
ColumnDefinitions="Auto,10,*">
<Image Grid.Column="0"
WidthRequest="60"
HeightRequest="60"
Aspect="AspectFill"
Source="{Binding ImageURL, Converter={StaticResource ImageSourceConverterKey}}" />
<StackLayout Grid.Column="2">
<Label
FontAttributes="Bold"
FontSize="16"
Text="{Binding Name}" />
<Label
VerticalOptions="End"
FontAttributes="Italic"
Text="{Binding Location}" />
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
728x90
▶ MainPage.xaml.cs
using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;
namespace TestProject;
/// <summary>
/// 메인 페이지
/// </summary>
public partial class MainPage : ContentPage
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainPage()
/// <summary>
/// 생성자
/// </summary>
public MainPage()
{
InitializeComponent();
List<Monkey> list = new List<Monkey>();
for(int i = 0; i < 10; i++)
{
list.Add
(
new Monkey
{
Name = "Baboon",
Location = "Africa and Asia",
ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Papio_anubis_%28Serengeti%2C_2009%29.jpg/
200px-Papio_anubis_%28Serengeti%2C_2009%29.jpg"
}
);
list.Add
(
new Monkey
{
Name = "Capuchin Monkey",
Location = "Central and South America",
ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg"
}
);
list.Add
(
new Monkey
{
Name = "Blue Monkey",
Location = "Central and East Africa",
ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/BlueMonkey.jpg/220px-BlueMonkey.jpg"
}
);
}
this.listView.ItemsSource = list;
Loaded += ContentPage_Loaded;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 컨텐트 페이지 로드시 처리하기 - ContentPage_Loaded(sender, e)
/// <summary>
/// 컨텐트 페이지 로드시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void ContentPage_Loaded(object sender, EventArgs e)
{
this.listView.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetIsFastScrollEnabled(true);
}
#endregion
}
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요