Hello,
I have a problem with the version 16.2. When I update the selecteditems programmatically. The list of selected items changes correcty in the UI, but when I dropdown the combobox, I still see the old items checked.
I split your post to a new thread as your question isn't directly related to the thread it was posted on. Note that I am a little confused on whether you are actually using Silverlight or WPF since the thread you followed up on was for Silverlight and you mention having the issue in 16.2 and our last Silverlight release was 16.1.
Please clarify if you are using Silverlight or WPF and it will also help if you can provide a sample that reproduces the behavior or enough information that we can create a sample by providing the relevant code where you are updating the selected items.
Hello, it's about wpf. Thanks
By the selection appears correct in the UI, are you referring to the text box portion of the combo after you update the selected items programatically. Also what is the relevant code that you are using to update the selection?
Yes, I mean text box portion gets updated but not the checkboxes.
I update it like this :
public ObservableCollection<object> Types { get { return _types; } set { _types = new ObservableCollection<object>(value); _types.CollectionChanged +=TypesOnCollectionChanged; OnPropertyChanged(); } } private void TypesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { Types = new ObservableCollection<object>(_defaultType); } OnPropertyChanged(nameof(Types)); }
The code provided doesn't really show how you are changing the selection of the XamComboEditor unless you are binding the selection to the Types property and if so it would be good to see that binding.
Note that I am not sure why you would change the instance of the collection when items are added to the observable collection, or is that meant to clear an existing selection if that collection is representing a collection of selected items? Also my expectation is that this code will result in a memory leak as the CollectionChanged event is never unhooked when the instance of the collection is changed.
Please provide more of the code including how your are using the XamComboEditor so it is clearer what is being done in your application.
Ok here's my use case. I have a list of types = {type1, type2, type3, Any}
and when the user checks the type "Any", I want to uncheck all the other types
here's my code :
<ig:XamComboEditor MaxWidth="150" AllowMultipleSelection="True" CheckBoxVisibility="Visible" ItemsSource="{Biding Path=AllTypes}" SelectedItems="{Binding Path=Types, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True,NotifyOnTargetUpdated=True}" DisplayMemberPath="Label" > </ig:XamComboEditor>
public ObservableCollection<object> Types { get { return _types; } set { _types = new ObservableCollection<object>(value); _types.CollectionChanged +=TypesOnCollectionChanged; OnPropertyChanged(); } } private void TypesOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var defaultType = AllTypes.SingleOrDefault(dt => dt.Name.Equals("Any")); if (e.Action == NotifyCollectionChangedAction.Add) { var newtype = e.NewItems.Cast<MyType>().SingleOrDefault(dt => dt.Equals(defaultType)); if (defaultType != null && Types.Count > 1) { Types = new ObservableCollection<object>(defaultType); } } OnPropertyChanged(nameof(Types)); }
Hello Aziz,
I have been investigating into this behavior you are reporting with the code that you have provided, and I have reproduced this behavior. This behavior is unexpected, and as such, I have asked our engineering staff to examine it further.
As a workaround for the time being, I would recommend that instead of utilizing the SelectedItems collection, that you use the IsSelectedMemberPath property of the XamComboEditor along with the SelectionChanged event. In this event, you can check the e.AddedItems for your "Any" item, and mark all other item's properties that are mapped to the IsSelectedMemberPath false. I am attaching a sample project to demonstrate this workaround.
To ensure that this unexpected behavior receives attention, I have logged it in our internal tracking systems with a development ID of 253805. The next step will be for a developer to review it and offer a fix or other resolution. It is worth noting that version 16.2 is not currently receiving active development, and so this resolution will be made in versions 17.1 and later. This can be seen from our product lifecycle page.
I have also created you a private support case so that you can track the status of this issue. It has an ID of CAS-196175-C7Z7B6, and you can access it here.
Please let me know if you have any other questions or concerns on this matter.
ComboSelectedItemsTestWorkaround.zip