Dane Balia
Dane Balia

Reputation: 5367

Extended WPF Toolkit - CheckComboBox

Is anyone aware of a way to manually enable (turning on the tick) on the Check Boxes within the CheckComboBox for WPFToolkit?

Unfortunately, the Items in the Combo-box are all strings.

I'm trying to enable all flags when "Select All" checkbox is ticked.

Upvotes: 0

Views: 3739

Answers (3)

Sadjad Esfandiari
Sadjad Esfandiari

Reputation: 461

One way in the code Behind is

var ComboSelector = MyCheckComboBox as  Xceed.Wpf.Toolkit.Primitives.Selector;
foreach(var item in MyCheckComboBox.Items)
ComboSelector.SelectedItems.Add(item);

Upvotes: 0

Bijington
Bijington

Reputation: 3751

This is a rather late response but I thought it best to post this in case it helps someone out. I have used the following approach for the WPFToolkit version:

public class Descriptor : INotifyPropertyChanged
{
    private bool isSelected;

    public bool IsSelected
    {
        get
        {
            return this.isSelected;
        }
        set
        {
            if (this.isSelected != value)
            {
                this.isSelected = value;
                // Raise INotifyPropertyChanged
            }
        }
    }

    public string Name { get; set; }
}

Create a collection of these and then assign them to the ItemsSource of the CheckComboBox.

To handle select all we have an option labelled: "" as the first item in the collection, then if this item is ticked all the items are de-selected and the all case is handle under the hood. To handle the selection Changed it does involve adding an event to the Descriptor class and firing it each time the IsSelected property is changed.

Upvotes: 3

Dane Balia
Dane Balia

Reputation: 5367

I eventually tossed out Extended WPFToolkit due to it's inability to access the checkboxes directly.

Instead I created a ComboBox and manually defined Checkboxes within it, which I access directly by name, and there able to implement a "Select All" by using it's [Checked/Unchecked[ event, and use the ComboBox SelectionChanged to show a default value that expresses what has been selected in a CSV format.

Maybe be clunky, but it gets the job done.

PS. I did not need to even bother with a DataTemplate for the ComboBox

Upvotes: 0

Related Questions