【发布时间】:2015-01-28 17:56:50
【问题描述】:
我有一个 ComboBox,它使用由 CheckBox 和 TextBlock 组成的 ItemTemplate。我的目标是,当项目被选中/取消选中时,折叠的组合框显示一个逗号分隔的选中项目列表。我认为 ComboBox 的 Text 属性可以用于此目的,但这仅在 IsEditable = true 时启用,否则即使绑定到属性也只是空白。我不希望组合可编辑。
如果我可以提供某种简单的模板来显示由列表中选中的项目组成的属性,那就太好了。这可能吗?
<ComboBox ItemsSource="{Binding Issues}" Text="{Binding IssuesCSV}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" Margin="4 0 4 0"
IsEnabled="{Binding IsEnabled}" />
<TextBlock Text="{Binding Issue.Number}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
【问题讨论】:
-
在这里试试codeproject.com/Articles/45782/…,它可能会给你一个方向
标签: wpf xaml combobox itemtemplate