Добавил кликер на новую страничку

This commit is contained in:
Vlad Torop 2025-03-05 09:27:37 +03:00
parent 3a5fdb7dab
commit 639f66993e
2 changed files with 19 additions and 4 deletions

View File

@ -5,12 +5,15 @@
Title="NewPage1"> Title="NewPage1">
<VerticalStackLayout> <VerticalStackLayout>
<Label <Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Label
Text="Новая страничка" Text="Новая страничка"
FontSize="30"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" /> HorizontalOptions="Center" />
<Button
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Fill" />
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

View File

@ -2,8 +2,20 @@ namespace MobailApp;
public partial class NewPage1 : ContentPage public partial class NewPage1 : ContentPage
{ {
int count = 0;
public NewPage1() public NewPage1()
{ {
InitializeComponent(); InitializeComponent();
} }
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
} }