1
我有一個組合框,它是可編輯的。所以用戶可以選擇一個項目,但是如果項目不存在,他可以輸入他想要的東西。但我的問題是,如果我選擇一個現有的項目,一切正常,並將其值設爲:獲取在可編輯組合框中鍵入的選定值?
<ComboBox Height="23" SelectedIndex="0" HorizontalAlignment="Left" Margin="104,73,0,0" Name="comboBox1" VerticalAlignment="Top" Width="159" IsEditable="True" SelectionChanged="comboBox1_SelectionChanged" />
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ToetsAlgemeneGegevensViewModel vm = (ToetsAlgemeneGegevensViewModel)this.DataContext;
if (comboBox1.SelectedValue != null && vm != null)
{
vm.Examination.Course = comboBox1.SelectedValue.ToString();
}
但是,如果我在輸入一些東西,我怎麼可以設置這個值?有人知道如何做到這一點?