start building apps with C# - Build something great…fast! - XAML, grid, VerticalStackLayout, Button
Head First C Sharp: A Learner’s Guide to Real-World Programming with C Sharp and .NET (Andrew Stellman(著)、Jennifer Greene(著)、O’Reilly Media)のChapter 1(start building apps with C# - Build something great…fast!)、p.35(Exercise)の解答を求めてみる。
Markup Language
MainPage.xaml
<?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="AnimalMatchingGame.MainPage">
<ScrollView>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Button x:Name="PlayAgainButton"
Text="Play again?"
FontSize="Large"
Clicked="PlayAgainButton_Clicked"/>
<Label x:Name="TimeElapsed"
Text="Time Elapsed: 0.0 seconds"
FontSize="Large"/>
<FlexLayout x:Name="AnimalButtons"
Wrap="Wrap"
MaximumWidthRequest="400">
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
<Button HeightRequest="100"
WidthRequest="100"
FontSize="60"
BackgroundColor="LightBlue"
BorderColor="Black"
BorderWidth="1"
Clicked="Button_Clicked"/>
</FlexLayout>
</VerticalStackLayout>
</ScrollView>
</ContentPage>