With the control like this:
this.xmceEntities.AllowMultipleSelection = true;this.xmceEntities.DisplayMemberPath = "CompanyId";this.xmceEntities.CheckBoxVisibility = Visibility.Visible;
To get selected data works perfectly with the property SeledtedItems
But when we need to set them i use a code like this:
/// <summary>
/// List of selected entities /// </summary> public override IList<Company> SelectedEntities { get { .... } set { this.xmceEntities.SelectedItems.Clear(); foreach (var item in value) { this.xmceEntities.SelectedItems.Add(item); }
....
} }
The display text show the companies ids as selected:
[1, 3, 5 ]
But in dropdown no one have the checkbox selected.
For some reason i did this to work:
this.xmceEntities.SelectedItems.Clear();
if (value != null) { foreach (var item in value) { var selectedCompany = this.xmceEntities.ItemsSource .Cast<Company>().SingleOrDefault(x => x.CompanyId == item.CompanyId);
if (selectedCompany != null) { this.xmceEntities.SelectedItems.Add(selectedCompany); } }
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.