Skip to content

Instantly share code, notes, and snippets.

@hilapon
Last active April 25, 2022 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hilapon/11244725bd4809a43e1ea268e20ea456 to your computer and use it in GitHub Desktop.
Save hilapon/11244725bd4809a43e1ea268e20ea456 to your computer and use it in GitHub Desktop.
ビューをビューモデルとバインドさせる
<?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"
xmlns:local ="clr-namespace:MauiApp1"
x:Class="MauiApp1.MainPage">
<ContentPage.BindingContext>
<local:MainViewModel />
</ContentPage.BindingContext>
<ScrollView>
<VerticalStackLayout Spacing="25" Padding="30">
<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level1"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />
<Label
Text="{Binding CounterText, Mode=OneWay}"
FontSize="18"
FontAttributes="Bold"
x:Name="CounterLabel"
HorizontalOptions="Center" />
<Button
Text="Click me"
FontAttributes="Bold"
SemanticProperties.Hint="Counts the number of times you click"
Command="{Binding CounterCommand}"
HorizontalOptions="Center" />
<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
WidthRequest="250"
HeightRequest="310"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ScrollView>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment