コンボボックス  
 
 
このサンプルに使用したXAMLです。 
  
  <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
 
        <Button x:Name="btnBack" Content="戻る" HorizontalAlignment="Left" Height="55" Margin="97,63,0,0" VerticalAlignment="Top" Width="162" FontSize="20" Background="#FFFF9A9A" Click="btnBack_Click" FontFamily="Global User Interface"/> 
 
        <ComboBox x:Name="cmb1" HorizontalAlignment="Left" Height="61" Margin="100,217,0,0" VerticalAlignment="Top" Width="646" FontSize="20" SelectionChanged="cmb1_SelectionChanged"/> 
 
        <ComboBox x:Name="cmb2" HorizontalAlignment="Left" Height="61" Margin="100,302,0,0" VerticalAlignment="Top" Width="646" FontSize="20" SelectionChanged="cmb2_SelectionChanged"/> 
 
        <TextBlock HorizontalAlignment="Left" Height="52" Margin="107,160,0,0" TextWrapping="Wrap" Text="質問" VerticalAlignment="Top" Width="329" FontSize="20"/> 
 
    </Grid> 
  
 
このサンプルでは選択したコンボボックスのインデックスで判定した結果を返しています。 
 
1個目のコンボボックスではどっちにするか?を選択させます。 
 
分岐したインデックスによってさらに質問を分岐させています。 
 
1個目と2個目のインデックスを用いて2個で選択した行動の結果について 
メッセージボックスで結果を返しています。 
 
選択されたインデックスを取得するには 
取得したインデックス = コンボボックスコントロールID->SelectedIndex; 
(例) 
index1 = cmb1->SelectedIndex; 
 
メッセージボックスは次のように 
表示させています。 
(例) 
auto message = ref new Windows::UI::Popups::MessageDialog(strMessage); 
message->ShowAsync(); 
 
コンボボックスのリストをクリアするには 
コンボボックスコントロールID->Items->Clear(); 
(例) 
cmb2->Items->Clear(); 
 
 
 
ヘッダファイルです。 
 
 
 
起動後の画面です。 
 
 
 
 
 | 
 |