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.
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.
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 Javier,
Thank you for your post. I have been looking into it and I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.