多选择组合框与复选框通用控制在wpf [英] Multi select combobox with checkbox generic control in wpf
问题描述
我想创建一个控件,允许用户从下拉菜单中选择多个选择。我在Google上搜索过,我有一些链接,例如
I want to create control which will allow user to select multiple selections from dropdown using check box.I have searched on Google and I got some links like
http://code.msdn.microsoft.com/windowsapps/Multi-选择ComboBox-in-cfbf1e22 / view / SourceCode#content 。
我发现这篇文章很有用,但我不能在每个应用程序中使用这个控件,因为ItemsSource类型可能在每个应用程序中更改。我想创建通用控件,将被任何应用程序使用可能有不同的ItemsSource。
如何创建可以在任何应用程序中使用的通用控件?我想为此控件创建DLL,并希望在所有应用程序中使用它。
I found this article useful but I can not use this control in every application because ItemsSource type may change in every application. I want to create generic control which will be used by any application which may have different ItemsSource. How do I create generic control which can be used in any application?I want to create DLL for this control and want to use it in all applications.
推荐答案
这里是你的示例
<ComboBox xmlns:sys="clr-namespace:System;assembly=mscorlib">
<ComboBox.Resources>
<Style TargetType="ComboBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<CheckBox>
<ContentPresenter />
</CheckBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.Resources>
<sys:String>item 1</sys:String>
<sys:String>item 2</sys:String>
<sys:String>item 3</sys:String>
<sys:String>item 4</sys:String>
</ComboBox>
结果
这篇关于多选择组合框与复选框通用控制在wpf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!