Загрузка данных
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="TravelDocumentsOrganizer.MainPage"
BackgroundColor="#F3F4F6">
<ScrollView>
<VerticalStackLayout Padding="20" Spacing="15">
<Label
Text="Органайзер поездки"
FontSize="32"
FontAttributes="Bold"
TextColor="#111827"
HorizontalOptions="Center"/>
<Frame
BackgroundColor="White"
CornerRadius="20"
Padding="15"
HasShadow="True">
<VerticalStackLayout Spacing="12">
<Entry
x:Name="titleEntry"
Placeholder="Название документа"
BackgroundColor="#F9FAFB"
TextColor="Black"/>
<Entry
x:Name="descriptionEntry"
Placeholder="Описание"
BackgroundColor="#F9FAFB"
TextColor="Black"/>
<Button
Text="Добавить документ"
BackgroundColor="#2563EB"
TextColor="White"
CornerRadius="12"
HeightRequest="50"
Clicked="OnAddClicked"/>
</VerticalStackLayout>
</Frame>
<Label
Text="Ваши документы"
FontSize="24"
FontAttributes="Bold"
TextColor="#111827"/>
<VerticalStackLayout
x:Name="documentsLayout"
Spacing="15"/>
</VerticalStackLayout>
</ScrollView>
</ContentPage>
namespace TravelDocumentsOrganizer;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnAddClicked(object sender, EventArgs e)
{
string title = titleEntry.Text;
string description = descriptionEntry.Text;
if (string.IsNullOrWhiteSpace(title) ||
string.IsNullOrWhiteSpace(description))
{
DisplayAlert(
"Ошибка",
"Введите все данные",
"OK");
return;
}
Label titleLabel = new Label
{
Text = title,
FontSize = 22,
FontAttributes = FontAttributes.Bold,
TextColor = Colors.Black
};
Label descriptionLabel = new Label
{
Text = description,
FontSize = 16,
TextColor = Colors.DarkGray
};
Button deleteButton = new Button
{
Text = "Удалить",
BackgroundColor = Colors.Red,
TextColor = Colors.White,
CornerRadius = 10,
HeightRequest = 45
};
VerticalStackLayout cardLayout = new VerticalStackLayout
{
Spacing = 10
};
cardLayout.Children.Add(titleLabel);
cardLayout.Children.Add(descriptionLabel);
cardLayout.Children.Add(deleteButton);
Frame card = new Frame
{
BackgroundColor = Colors.White,
CornerRadius = 20,
Padding = 15,
HasShadow = true,
Content = cardLayout
};
deleteButton.Clicked += (s, args) =>
{
documentsLayout.Children.Remove(card);
};
documentsLayout.Children.Add(card);
titleEntry.Text = "";
descriptionEntry.Text = "";
}
}