0

我有ComboBox一个窗口绑定到表中字段的数据。该字段可以为空。我将查找表绑定ItemsSourceComboBox. 我发现如果数据表中的数据在字段中为空,则组合框将显示CollectionViewSource我绑定到ItemsSource(查找表)中的第一个内容。那不是我想要的。我读过我应该使用 的 的属性TargetNullValueSelectedValue但是ComboBox当我这样做时它总是会引发错误。这是 XAML:

<ComboBox x:Name="cmbMajorProbByInterviewer"
      VerticalAlignment="Top"
      ItemsSource="{Binding Source={StaticResource aSICodesSubstanceTypeViewSource2}}"
      DisplayMemberPath="SubstanceDesc"
      SelectedValue="{Binding MajorProblemByInterviewer, TargetNullValue={x:Static sys:String.Empty}}"
      SelectedValuePath="SubstanceType"
      Grid.Column="3" />

每次我进入这个窗口时,我得到的错误是:“获取 ASICCodesSubstanceType 的数据时出错。输入字符串的格式不正确。”

我试过TargetNullValue=''andTargetNullValue=' 'TargetNullValue='None'and TargetNullValue=,但所有这些都会抛出同样的错误。我究竟做错了什么?

4

0 回答 0