我想重置ComboBox以清空它, 我有一个例子是正确的,但另一个是错误的。
两个组合框绑定到枚举列表:
Enum Brand:
public enum IdentificationDeviceBrand:int { FMC = 1, DMM = 2, HTC = 3 }
枚举类型:
public enum IdentificationTypes : int
{
TerminalEntryGate = 1,
TerminalExitGate = 2,
LoadingAreaEntryGate = 3,
LoadingAreaExitGate = 4,
IslandEntryGate = 5,
IslandExitGate = 6
}
我重置了Combobox:
对于类型正常
组合框BRAM的XAML:
<ComboBox Name="comboBrand"
Validation.ErrorTemplate="{StaticResource TextBoxErrorTemplate}"
ItemsSource="{Binding BrandEnum}" SelectedItem="{Binding SelectedBrand, NotifyOnValidationError=True, TargetNullValue=''}"
SelectedValuePath="id" />
答案 0 :(得分:1)
如果您只是想删除文本,则应删除Validation.ErrorTemplate
属性:
<ComboBox Name="comboBrand"
ItemsSource="{Binding BrandEnum}"
SelectedItem="{Binding SelectedBrand, NotifyOnValidationError=True, TargetNullValue=''}"
SelectedValuePath="id" />