【发布时间】:2017-03-01 22:45:24
【问题描述】:
WPF 中组合框的“SelectedValue”具有正确的值,但带有命名空间的附加文本。我在关注 MVVM,“SelectedValue”绑定到“SelectedImage”属性。
如果我选择第一个comboBoxItem,它的值为“System.Windows.Controls.ComboBox:Firmware Image 1”。
如何只获取选定的值?
<ComboBox Grid.Row="1"
Grid.Column="1"
Width="150"
Height="30"
ToolTip="Store Identification"
Margin="0,2,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Background="#FF1649A0"
BorderBrush="White"
Foreground="White"
SelectedValue="{Binding SelectedImage}">
<ComboBox.Items>
<ComboBoxItem Content="Firmware Image 1 " />
<ComboBoxItem Content="Firmware Image 2" />
</ComboBox.Items>
</ComboBox>
【问题讨论】: