ComboBoxのイベント「SelectionChange」があります。選択したインデックスのテキストを取得するWPF ComboBox
ここで私がやろうとしているものです:
- 私は2番目コンボボックスがComboBox2はできるだけ早く反応すべき
- 最初のボックスで選択した項目に応じたアイテムが表示されます2つのコンボボックス
- を持っていますComboBox1の項目が選択されています
私の問題は、SelectedIndexを取得しようとしているときです。
SelectedIndexを確認した後でComboBox1.Textを使用すると、ComboBox2が反応しないようにnullが返されます。
イベントを強制するためにボタンを配置しようとしましたが、動作しました。フォーカスを解放するまで、SelectedIndexは変更されないようです。バインディング使用のよう
<ComboBox Height="23" HorizontalAlignment="Left" Margin="166,12,0,0" Name="cbox_year" VerticalAlignment="Top" Width="120" SelectionChanged="cbox_year_SelectionChanged">
<ComboBoxItem Content="1st Year/1st Sem" />
<ComboBoxItem Content="1st Year/2nd Sem" />
<ComboBoxItem Content="2nd Year/1st Sem" />
<ComboBoxItem Content="2nd Year/2nd Sem" />
<ComboBoxItem Content="3rd Year/1st Sem" />
<ComboBoxItem Content="3rd Year/2nd Sem" />
<ComboBoxItem Content="4th Year/1st Sem" />
<ComboBoxItem Content="4th Year/2nd Sem" />
</ComboBox>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="166,41,0,0" Name="cb_subj" VerticalAlignment="Top" Width="120" SelectionChanged="cb_subj_SelectionChanged" />
関連するXAMLを投稿できますか?また、あなたのコード部分はどのイベントハンドラですか? –
これは、ボックスのSelectionChangedイベントの一部です – Nath