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

New Post: CheckComboBox selectedItems

$
0
0
Hi,

As stated in the documentation, "CheckComboBox.SelectedItems : Gets the collection of checked items."
This cannot be set.

As stated in the documentation, "CheckComboBox.SelectedItemsOverride : Gets or sets a custom IList of selected items."
This is a get/set property.
It lets you set the list of selectedItems, but will always be null if you don't set it.
What you want is to work the this property :
<StackPanel>
    <xctk:CheckComboBox x:Name="UserGroupsCheckedComboBox"
                        ItemsSource="{Binding UserGroups}"
                        SelectedItemsOverride="{Binding SelectedUserGroups}"
                        DisplayMemberPath="Name"
                        ValueMemberPath="ID" />

    <StackPanel Margin="0,200,0,0"
                Orientation="Horizontal">
      <TextBlock Text="SelectedItems : " />
      <TextBlock Text="{Binding SelectedItemsOverride.Count, ElementName=UserGroupsCheckedComboBox}" />
    </StackPanel>
   
  </StackPanel>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      this.UserGroups = new ObservableCollection<MyData>()
      {
        new MyData() { ID = 1, Name = "First" },
        new MyData() { ID = 2, Name = "Second" },
        new MyData() { ID = 3, Name = "Third" },
        new MyData() { ID = 4, Name = "Fourth" },
        new MyData() { ID = 5, Name = "Fifth" },
      };
      this.SelectedUserGroups = new ObservableCollection<MyData>() { this.UserGroups[ 2 ] };
      this.DataContext = this;
    }

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

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

  public class MyData
  {
    public string Name
    {
      get;
      set;
    }

    public int ID
    {
      get;
      set;
    }
  }
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF

Viewing all articles
Browse latest Browse all 4964

Trending Articles



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