この記事では RadioButton をグループ化する方法について説明をします。
環境
| 開発環境 | Microsoft Visual Studio Enterprise 2019 Version 16.11.5 |
| Framework | Microsoft .NET Framework Version 4.8.04161 |
RadioButton のグループ化
RadioButton をグループ化するには RadioButtons を使用します。
以下に、RadioButttons を使用して果物と野菜の2つのグループを作成する例を示します。
<RadioButtons>を使用すると <x:String> でラジオボタンアイテムを作成することができます。またグループ化されますので、それぞれのグループごとに1つのアイテムをチェックすることができます。
XAML の例
<Window
x:Class="WinUISample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUISample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="果物" />
<RadioButtons>
<x:String>リンゴ</x:String>
<x:String>ミカン</x:String>
<x:String>バナナ</x:String>
</RadioButtons>
<TextBlock Text="野菜" />
<RadioButtons>
<x:String>キュウリ</x:String>
<x:String>ナス</x:String>
<x:String>ジャガイモ</x:String>
</RadioButtons>
</StackPanel>
</Window>
WinUi Tips
本サイトでまとめている WinUI Tips の一覧はこちらから確認できます。
Please follow and like us:


コメント