本記事の概要
この記事では RadioButton の基本使用方法について説明をします。
公式サイト情報はコチラを参照してください。
RadioButton の基本使用方法
XAML で RadioButton を作成するには <RadioButton> を使用します。
また、表面に表示する文字列は Content プロパティを、チェック状態にするには IsChecked プロパティに True を設定します。
以下の例では、RadioButton で3つの選択肢「Red」「Green」「Blue」を作成し、「Green」をチェック状態にします。
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="MauiAppSample.MainPage"> <ScrollView> <VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="StartAndExpand"> <RadioButton Content="Red" /> <RadioButton Content="Green" IsChecked="True"/> <RadioButton Content="Blue" /> </VerticalStackLayout> </ScrollView> </ContentPage>
.NET MAUI Tips
本サイトでまとめている .NET MAUI Tips の一覧はこちらから確認できます。
Please follow and like us:
コメント