今回はComboBoxコントロールに選択項目を表示する方法を理解していきましょう
MainPage.xamlのComboBoxを1つ配置し、選択項目をを3つ配置するXamlを以下に示します。
選択項目は<ComboBoxItem>の中に記述します。
<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ComboBox x:Name="comboBox" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="142"> <ComboBoxItem>アイテム1</ComboBoxItem> <ComboBoxItem>アイテム2</ComboBoxItem> <ComboBoxItem>アイテム3</ComboBoxItem> </ComboBox> </Grid> </Page>
上記を実行すると、ComboBoxには3つの選択肢が表示されるようになります。
Please follow and like us:
コメント