This project has moved. For the latest updates, please go here.

CheckComboBox

Derives from Xceed.Wpf.Toolkit.Primitives.Selector

CheckComboBox is a combo box in which the items in the dropdown are preceded by a checkbox. As items are checked or unchecked, the Text property displayed above the dropdown is updated using the concatenated string representations of the checked items. The text displayed is formated using the value of the Delimiter property to separate the individual strings.

checkcombobox.jpg

         <xctk:CheckComboBox x:Name="_combo" 
                             HorizontalAlignment="Center" 
                             VerticalAlignment="Center" 
                             DisplayMemberPath="Color"
                             ValueMemberPath="Level"
                             SelectedValue="{Binding SelectedValue}"
                             SelectedItems="{Binding SelectedItems}" />


Properties

Property Description
Command Gets or sets the command to execute when an item is checked/unchecked. (Inherited from Selector)
Delimiter Gets or sets the string used to separate the concatenated string representations of the checked items. (Inherited from Selector)
IsDropDownOpen Gets or sets a value indicating whether the combo box drop-down is currently open.
IsEditable Gets or sets a value that enables or disables editing of the text in the Textbox of the CheckComboBox. Values entered must be seperated by the Delimiter. Values entered that are not in the list or that are duplicates will be removed. Selection will be active on LostFocus. Default is False.
MaxDropDownHeight Gets or sets the maximum height of the popup.
SelectedItem Gets or sets the last checked item. (Inherited from Selector)
SelectedItems Gets the collection of checked items. (Inherited from Selector)
SelectedItemsOverride Gets or sets the list of SelectedItems. (Inherited from Selector)
SelectedMemberPath Gets or sets a path to a value on the source object used to determine whether an item is selected. (Inherited from Selector)
SelectedValue Gets or sets a string containing the selected items separated by the value of Delimiter (ex., "Item1, Item2, Item3"). (Inherited from Selector)
Text Gets or sets the formated text of the currently checked items.
ValueMemberPath Gets or sets a path to a value on the source object representing the value to use. (Inherited from Selector)

Events

Event Description
ItemSelectionChanged Raised when an item's selection is changed. (Inherited from Selector)


Support this project, check out the Plus Edition.
---

Last edited Jun 1, 2016 at 3:47 PM by dlafontaine, version 13

Comments

tchien69 Apr 26 at 6:05 AM 
Is there some kind of copy protection on this toolkit?!? I was using CheckComboBox, DataGridControl and DateTimePickerjust fine for a few weeks until I got some weird error while ending debugging. Ever since then, all 3 (and only the Xceed vs. NET) Controls show up as invisible (except for resize box the Designer puts around it when you select it)!?! I tried reopening the Solution / Visual Studio and switching to a backup copy of my entire Project. The backup copy worked - UNTIL I renamed its Solution back to the primary name!?! Apparently, the problem occurs *only* with my normal Solution name!?! If I add/drop/change even a single character on the Solution name, the problem goes away!?! ARRRRRRRRGHHHHH!!!

BoucherS Apr 6 at 3:11 PM 
Discussion has been created for the last comments : https://wpftoolkit.codeplex.com/discussions/662425#

tchien69 Apr 5 at 6:38 PM 
Also, "SelectedItemsOverride" Property (the actual "CheckComboBox"'s Property not the View Model's Binding Property) seems to always be "null" even though there are items selected (as reflected in the "SelectedItems" Property). I need to be able to write to and read from the whatever Property(ies) necessary to initially set / update / read the selected items in "CheckComboBox" via MVVM.

tchien69 Apr 5 at 6:01 PM 
I'm getting a "The property "SelectedItems" does not have an accessible setter." error from the following XAML:

"
<xctk:CheckComboBox x:Name="UserGroupsCheckedComboBox" Grid.Row="1" Grid.Column="0"
ItemsSource="{Binding UserGroups}"
SelectedItems="{Binding SelectedUserGroups, Mode=OneWayToSource}"
SelectedItemsOverride="{Binding SelectedUserGroupsOverride}"
DisplayMemberPath="Name"
ValueMemberPath="ID"
Command="{Binding OnUserGroupsChangedCommand}"
Width="200"
HorizontalAlignment="Left"
VerticalAlignment="Center"
>
</xctk:CheckComboBox>
"

leo_cs Feb 19 at 4:36 PM 
Found it eventually...
For anyone who is looking for how to change the highlight colors, add the following Style to your resources and use the IsMouseOver section:

<Style TargetType="{x:Type xctk:SelectorItem}">
<!--<Setter Property="Background" Value="{DynamicResource {x:Static xctk:themes:ResourceKeys.ControlNormalBackgroundKey}}" />-->
<Setter Property="IsTabStop" Value="False" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type xctk:SelectorItem}">
<Border x:Name="_background"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<CheckBox Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}"
Content="{TemplateBinding Content}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="_background" Property="Background" Value="{StaticResource FocusColor}" />
<Setter TargetName="_background" Property="BorderBrush" Value="{StaticResource FocusColor}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

leo_cs Feb 17 at 9:20 PM 
Thanks, that worked.
Following the same logic, I've tried setting also the item highlight color but it doesn't work (using FocusColor or an explicit value).

What am I doing wrong?:

<Style TargetType="ComboBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border x:Name="Border" BorderBrush="{StaticResource ControlBackgroundColor}">
<ContentPresenter />
</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource FocusColor}"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="False">
<Setter Property="Panel.Background" TargetName="Border" Value="{StaticResource ControlBackgroundColor}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

BoucherS Feb 17 at 1:49 PM 
Try setting a style for CheckBox :
<xctk:CheckComboBox>
<xctk:CheckComboBox.Resources>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="BorderBrush" Value="Red" />
</Style>
</xctk:CheckComboBox.Resources>
</xctk:CheckComboBox>

leo_cs Feb 17 at 8:50 AM 
How would I change the checkbox color (i.e. the border of the box)?
I played a bit with different BorderBrush options in the template, but couldn't find it.

BoucherS Dec 21, 2015 at 1:38 PM 
Hi,

The CheckBox control is not part of the Extended WPF Toolkit, it's a Microsoft control.
Anyway, you can remove the "ContentPresenter" from ContentPresenter.Content" ans use "Text="{TemplateBinding Content}"".
You can then use the CheckBox this way :
<CheckBox Content="Blabla"/>

dacid78 Dec 18, 2015 at 3:45 PM 
Hello, I want skin the checkbox, but the text don't show:
<Style TargetType="{x:Type CheckBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
...
<TextBlock Text="{TemplateBinding ContentPresenter.Content}" TextWrapping="Wrap"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
But the "{TemplateBinding ContentPresenter.Content}" return empty.
What is the property to binding ?

BoucherS Feb 20, 2015 at 1:29 PM 
Discussion https://wpftoolkit.codeplex.com/discussions/581461 has been created.

shajahan Feb 16, 2015 at 11:13 AM 
How to select all item in checkcombobox by clicking select all item which is in checkcombobox....
any idea about that

BoucherS Mar 27, 2014 at 2:52 PM 
Hi,
Yes, the documention will need to be updated. If you want examples on how to use the Toolkit, please download the LiveExplorer App available on this page : https://wpftoolkit.codeplex.com/.
It contains many examples and you have access to the XAML and code-behind through the LiveExplorer. Unfortunately, it doesn't contains examples with the property "SelectedItemsOverride".
The Property "SelectedItems" is Get only, not Get/Set.
The Property "SelectedItemsOverride" is used to set a list of SelectedItems to the CheckComboBox.
Here's how to use it :
<xctk:CheckComboBox x:Name="_checkComboBox"
Width="125"
Height="22"
ItemsSource="{Binding MyCollection}"
SelectedItemsOverride="{Binding MySelectedObjects}">
</xctk:CheckComboBox>

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
_checkComboBox.DataContext = this;
this.MyCollection = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
this.MySelectedObjects = new ObservableCollection<int>() { this.MyCollection[ 0 ], this.MyCollection[ 2 ] };
}
public ObservableCollection<int> MyCollection
{ get; set; }

public ObservableCollection<int> MySelectedObjects
{ get; set; }
}

thelehehmanlip Mar 27, 2014 at 2:14 PM 
This "documentation" page is totally useless. It does not give a valid example of how to use this product, and even references properties that aren't even accessible. I get a build error trying to use SelectedItems. SelectedItemsOverride exists, but there's no mention of how it works on this page. Trying to bind to it, I don't have any two way access.

BoucherS Feb 6, 2014 at 1:32 PM 
Set the ItemsSource and SelectedItemsOverride to the same List of items :
_checkComboBox.ItemsSource = myList;
_checkComboBox.SelectedItemsOverride = myList;

prasant38 Feb 6, 2014 at 9:06 AM 
Please suggest me how to check all checkboxes in CheckComboBox by default

BoucherS Jan 21, 2014 at 7:19 PM 
Discussion https://wpftoolkit.codeplex.com/discussions/517953 has been created.

sriharshakolluru Jan 21, 2014 at 5:53 AM 
Please post a code snippet on how to bind data to this checkedcomb box. I find it difficult to understand how to pass two data valus, one containing the total Items and the other containing selected items of these.

I tried the following and it worked but I just want to bind a single data source.
1. I set
cmbBox.Itemsource=listOfItems;

2. I added the items to be selected to the SelectedItems property using a foreach loop. And these items are also added in the
foreach(string str in LstSelectedItems)
cmbBox.SelectedItems.Add(str);

But there should be a better option right??

BoucherS Dec 17, 2013 at 8:22 PM 
Hi, can you please create a discussion tab and submit a code snippet of problem ?
Thanks

AXG1010 Dec 11, 2013 at 4:36 PM 
I get strange non-working behavior with this control. The last checked item does not show the check box as marked (even though it is listed in the concatenated value). The binding to SelectedValue also does not work. I found an older version of the source (at the time I didn't realize it was an older release, was going to use it to step through the code and see what I was doing wrong) on GitHub, but that version seemed to work just fine (at least for this control, I didn't test the others). I guess I'm probably just going to make my own version of this control since I don't have to to wait for an update...too bad, it was exactly what I needed.

wbradney Aug 15, 2013 at 6:28 PM 
This doesn't bind when it placed inside a DataTemplate. What am I missing?

fun_vikas Apr 28, 2013 at 7:19 AM 
When I select an item in combobox... its text changes to checkedCombobox.selecteditem.value:ITEM1
Ho can that be fixed?

rahulpatil2009 Oct 29, 2012 at 10:34 AM 
the binding does not work correctly when the combo box is bound to a source which is changed at runtime. e.g. ItemSource=>Country.AvailableStates and SelectedItems=>Country.SelectedStates, in this case when 'Country' object is changed, selected values for first country are still there in 'SelectedValues' as well as 'Text' properties

to fix this issue, we need to modify source code to make 'Selector.UpdateSelectedValue' method 'Public' (Selector is base class for this combo box) and call this method on combo boxes whenever a source object changes (Country in above example)

timmyboyyy Mar 16, 2012 at 12:14 PM 
When will it be available?

momarf Feb 22, 2012 at 10:57 PM 
It will be very useful if SelectedItems is TwoWay property. Currently it is oneway which means we can only set SelectedValue property and pass delimeter separated Value Property values.