Change app to a basic ToDo manager

This commit is contained in:
Manuel Thalmann 2024-06-06 23:28:49 +02:00
parent 4bfc83715f
commit 37f27fa415
2 changed files with 38 additions and 40 deletions

View file

@ -5,33 +5,43 @@
x:Class="TodoDetails.MainPage"> x:Class="TodoDetails.MainPage">
<ScrollView> <ScrollView>
<VerticalStackLayout <CollectionView>
Padding="30,0" <CollectionView.ItemsSource>
Spacing="25"> <x:Array Type="{x:Type model:Todo}">
<Image <model:Todo Title="Create ViewModel"
Source="dotnet_bot.png" Description="Create a ViewModel in the next step to learn MVVM."
HeightRequest="185" Category="Default"
Aspect="AspectFit" IsDone="False"/>
SemanticProperties.Description="dot net bot in a race car number eight" /> <model:Todo Title="Add Theming"
Description="Integrate your own theme in the app."
<Label Category="Default"
Text="Hello, World!" IsDone="False"/>
Style="{StaticResource Headline}" <model:Todo Title="Add local database"
SemanticProperties.HeadingLevel="Level1" /> Description="Learn how to add a local database to work with (optional)."
Category="Default"
<Label IsDone="False"/>
Text="Welcome to &#10;.NET Multi-platform App UI" </x:Array>
Style="{StaticResource SubHeadline}" </CollectionView.ItemsSource>
SemanticProperties.HeadingLevel="Level2" <CollectionView.ItemTemplate>
SemanticProperties.Description="Welcome to dot net Multi platform App U I" /> <DataTemplate x:DataType="model:Todo">
<HorizontalStackLayout Padding="10"
<Button Spacing="10"
x:Name="CounterBtn" HorizontalOptions="FillAndExpand">
Text="Click me" <CheckBox IsChecked="{Binding IsDone}"
SemanticProperties.Hint="Counts the number of times you click" VerticalOptions="Start"/>
Clicked="OnCounterClicked" <VerticalStackLayout VerticalOptions="Center">
HorizontalOptions="Fill" /> <Label Text="{Binding Title}"
</VerticalStackLayout> VerticalOptions="Center"
FontSize="16"
TextColor="Gray"/>
<Label Text="{Binding Category}"
FontSize="12"
TextColor="Gray"/>
</VerticalStackLayout>
</HorizontalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView> </ScrollView>
</ContentPage> </ContentPage>

View file

@ -1,4 +1,4 @@
namespace TodoDetails namespace TodoDetails
{ {
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
@ -8,18 +8,6 @@
{ {
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);
}
} }
} }