Home Forums WPF controls Xceed Toolkit Plus for WPF Select all feature in CheckCombobox

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • deepakkumar19
    Participant
    Post count: 2
    #44535 |

    Is there any “select all” feature in checkcombobox of xceed.wpf.toolkit ?

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    Currently no, but we have created a case to add this feature in the future.

    In the meantime, you can add a “Select All” option to your CheckComboBox. Here’s how :

    Use you own CheckComboBox to overwrite the UpdateText() method and not display the “Select All” as a selected item in the Textbox. Add a listener to event ItemSelectionChanged to select all items when “Select All” is chosen.

    <local:MyCheckComboBox x:Name=”_checkComboBox”
    VerticalAlignment=”Center”
    ItemSelectionChanged=”ItemSelectionChanged”/>

    public partial class MainWindow : Window
    {
    List<string> initialList = new List<string>() { “First”, “Second”, “Third” };

    public MainWindow()
    {
    InitializeComponent();

    foreach( var item in initialList )
    {
    _checkComboBox.Items.Add( item );
    }
    _checkComboBox.Items.Add( “Select All” );
    }

    private void ItemSelectionChanged( object sender, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventArgs e )
    {
    var item = e.Item;
    if( item.Equals( “Select All” ) )
    {
    // Select All
    if( e.IsSelected )
    {
    foreach( var data in _checkComboBox.Items )
    {
    var selectorItem = _checkComboBox.ItemContainerGenerator.ContainerFromItem( data ) as SelectorItem;
    if( ( selectorItem != null ) && !selectorItem.IsSelected )
    {
    _checkComboBox.SelectedItems.Add( data );
    }
    }
    }
    }
    else
    {
    // UnSelect an item => make sure the “Select All” option is not selected.
    if( !e.IsSelected )
    {
    _checkComboBox.SelectedItems.Remove( “Select All” );
    }
    }
    }
    }

    public class MyCheckComboBox : CheckComboBox
    {
    protected override void UpdateText()
    {
    // Do not display the “Select All” in the TextBox.
    var selectedItemsList = this.SelectedItems.Cast<object>().Select( x => this.GetItemDisplayValue( x ) ).Where( x => !x.Equals( “Select All” ) );

    var newValue = String.Join( this.Delimiter, selectedItemsList );
    if( String.IsNullOrEmpty( this.Text ) || !this.Text.Equals( newValue ) )
    {
    this.SetCurrentValue( CheckComboBox.TextProperty, newValue );
    }
    }
    }

    deepakkumar19
    Participant
    Post count: 2

    I was able to implement the code you provided except for update text method. It is not able to find that method to override.

    Also, i wanted it more to behave like excel filter “Select All”, like by default everything checked and then change the selection based on the search or select. Is there anything like that there ?

    Diane [Xceed]
    Moderator
    Post count: 1353

    This is to inform you that the following issue was fixed in the latest version (Toolkit for WPF v3.4):
    “In CheckComboBox and CheckListBox, a “Select All” option will now be supported.”

    Download Link: http://forums.xceed.com/latest-xceed-toolkit-plus-for-wpf

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.