我在xaml的主窗口中设置了一个组合框,但是当我尝试获取索引时,我在代码中获得了一个空引用。为什么呢?
ComboBox Name="cmbo_addvar_datatype" Margin="4,0,1,0" Grid.Row="10" Grid.ColumnSpan="2" ToolTip="Select a datatype for the variable being added." SelectionChanged="test_addedVar">
<ComboBoxItem IsSelected="True" ToolTip="True/Flase value.">Boolean</ComboBoxItem>
<ComboBoxItem ToolTip="">Little</ComboBoxItem>
<ComboBoxItem>Big</ComboBoxItem>
<ComboBoxItem ToolTip="Text value">String</ComboBoxItem>
<ComboBoxItem ToolTip="Value with a decimal point">Decimal</ComboBoxItem>
<ComboBoxItem ToolTip="List of strings.">String list</ComboBoxItem>
<ComboBoxItem ToolTip="Array of type little">Array(little)</ComboBoxItem>
<ComboBoxItem ToolTip="Array of type big">Array(big)</ComboBoxItem>
</ComboBox>
mainwindow.xaml.vb
Dim dataType As String = cmbo_addvar_datatype.SelectedIndex