简体   繁体   English

组合框复选框显示

[英]Combobox checkbox display

Just new in WPF, I'm trying to do a combobox that allows people to select the keywords, by checking them. WPF中的新功能,我正在尝试创建一个组合框,使人们可以通过选中它们来选择关键字。 Below is my XAML 以下是我的XAML

<ComboBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <CheckBox Tag="{Binding Path=TagID}"
                      Content="{Binding Path=Tag}"
                      Margin="10,0,0,0"></CheckBox>
        </StackPanel>
    </DataTemplate>
</ComboBox.ItemTemplate>

the question is, how do I create a custom display ? 问题是,如何创建自定义显示 for example, the user selected three items. 例如,用户选择了三个项目。 Instead of the selected item and the checkbox being displayed in the combo box text. 而不是所选项目,并且复选框显示在组合框文本中。 I want the three selected items to be the ones displayed in the combobox text? 我希望三个选定的项目成为combobox文本中显示的项目吗?

尝试使用ItemContainerStyle属性,该属性可让您指定模板的容器

Sounds like you want a multi-select combobox. 听起来好像您想要一个多选组合框。 I found this example here to be useful when creating one: 我发现这里的示例在创建一个示例时非常有用:

http://www.c-sharpcorner.com/UploadFile/1a81c5/multi-select-combobox-in-wpf/ http://www.c-sharpcorner.com/UploadFile/1a81c5/multi-select-combobox-in-wpf/

Apologies for not adding code but this article is pretty comprehensive! 很抱歉没有添加代码,但是本文非常全面!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM