【发布时间】:2015-04-14 14:59:17
【问题描述】:
我的组合框在列表中正确显示我的所有数据,但不显示所选项目,而不是我只有我的对象的名称。
没有项目模板它工作正常,但我需要它来显示我的数据。我做错什么了吗?如何让我选择的项目显示在同一个 dataTemplate 中?
<ComboBox Grid.Row="2"
Grid.Column="1"
Style="{StaticResource myComboBox}"
x:Name="ComboBoxProtocole"
IsEditable="True"
IsTextSearchEnabled="True"
TextSearch.Text="labelFull"
ItemsSource="{Binding}"
>
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding labelShort}" FontSize="12"/>
<TextBlock Text="{Binding labelFull}" FontSize="10" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
【问题讨论】:
-
itemsSource 绑定到什么?
-
它绑定到我的数据上下文,我的对象的可观察集合
标签: wpf xaml selecteditem