I need to know when the list has been reordered. I see that there is a ChildrenReordered event, but I can't get it to fire. Would you please provide the code behind C# code to handle when the list has been reordered?
Thanks!
2 Answers, 1 is accepted
0
Ves
Telerik team
answered on 20 Feb 2017, 11:59 AM
Hi Ron,
ChildrenReordered event is exposed by Xamarin.Forms.VisualElement and it is not applicable in this case. Instead, you can handle the CollectionChanged event of the ItemsSource, provided, that the items source is an observable collection. The CollectionChanged event will be triggered twice -- once with Remove action and second time with Add. Here is a sample:
public lv000()
{
InitializeComponent();
this.listView.ItemsSource = new ObservableCollection<string>(from c in Enumerable.Range(0, 50) select "Item " + c);
(this.listView.ItemsSource as ObservableCollection<string>).CollectionChanged += Lv000_CollectionChanged;
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
{
var removedItem = e.OldItems[0];
}
else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
var addedItem = e.NewItems[0];
}
}
Best regards,
Ves
Telerik by Progress
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items