Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi select combobox with checkbox generic control in wpf

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-Select-ComboBox-in-cfbf1e22/view/SourceCode#content.

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.

like image 904
DT sawant Avatar asked Aug 06 '14 10:08

DT sawant


1 Answers

here is a sample for you

<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>

result

result

like image 184
pushpraj Avatar answered Oct 19 '22 00:10

pushpraj