Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: select all item in checkcombobox

$
0
0
Hi,
Try this :
<xctk:CheckComboBox x:Name="_checkComboBox"
                          ItemsSource="{Binding MyData}"
                          ItemSelectionChanged="_checkComboBox_ItemSelectionChanged_1"
                          Width="250"
                          Height="25"/>

public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();

      _checkComboBox.DataContext = this;

      this.MyData = new ObservableCollection<string>()
      {
        "First", "Second", "Third", "Fourth", "Fifth", "SelectAll"
      };
    }

    public ObservableCollection<string> MyData
    {
      get;
      set;
    }

    private void _checkComboBox_ItemSelectionChanged_1( object sender, Xceed.Wpf.Toolkit.Primitives.ItemSelectionChangedEventArgs e )
    {
      var checkComboBox = sender as CheckComboBox;
      if( checkComboBox != null )
      {
        if( e.IsSelected && object.Equals( e.Item, this.MyData.Last() ) )
        {
          checkComboBox.SelectedItemsOverride = new ObservableCollection<string>( this.MyData );
        }
        else if( !e.IsSelected )
        {
          if( checkComboBox.SelectedItems.Contains( this.MyData.Last() ) )
          {
            checkComboBox.SelectedItems.Remove( this.MyData.Last() );
          }
        }
      }
    }
  }

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>