Xaml 绑定到db表的ComboBox最初应为空
我有一个WPF组合框控件绑定到数据库表中的edm字段。这可以很好地工作,只是它在启动时在控件中输入了第一个值,这是不需要的。这是xamlXaml 绑定到db表的ComboBox最初应为空,xaml,Xaml,我有一个WPF组合框控件绑定到数据库表中的edm字段。这可以很好地工作,只是它在启动时在控件中输入了第一个值,这是不需要的。这是xaml <ComboBox x:Name="cbMeasure" Width="104" ItemsSource="{Binding Source={StaticResource ddMeasureViewSource}}" DisplayMemberPath="Measure"
<ComboBox x:Name="cbMeasure"
Width="104"
ItemsSource="{Binding Source={StaticResource ddMeasureViewSource}}"
DisplayMemberPath="Measure"
IsSynchronizedWithCurrentItem="True"
SelectedValuePath="Measure"
SelectedValue="{Binding Measure1}"/>
因此,输入组合框选择中的“一”,并填充测量1变量。好的,我找到了解决方案。您必须将IsSynchronizedWithCurrentItem属性设置为false,我想我已经尝试过了,但我想我刚刚删除了该属性,默认值必须为true。所以xaml看起来像
<ComboBox x:Name="cbMeasure" Width="104" Text="{Binding Measure1}">
<TextBlock Text="one"/>
<TextBlock Text="two"/>
<TextBlock Text="three"/>
<TextBlock Text="four"/>
</ComboBox>
<ComboBox x:Name="cbMeasure"
Width="104"
ItemsSource="{Binding Source={StaticResource ddMeasureViewSource}}"
DisplayMemberPath="Measure"
IsSynchronizedWithCurrentItem="False"
SelectedValuePath="Measure"
SelectedValue="{Binding Measure1}"/>
希望这有助于其他人谁试图找到这种类型的绑定信息
<ComboBox x:Name="cbMeasure"
Width="104"
ItemsSource="{Binding Source={StaticResource ddMeasureViewSource}}"
DisplayMemberPath="Measure"
IsSynchronizedWithCurrentItem="False"
SelectedValuePath="Measure"
SelectedValue="{Binding Measure1}"/>