Hello guys,
I am looking for the List View having long press functionality. Actually I am showing the data in List View. As soon as I long press any item, each item get check box in front it. So is it possible to do such type of functionality in xamarin forms. Please help.
Thank you.
4 Answers, 1 is accepted
You'll find all the functionality for RadListView selection here.
Anything else, you'd need to implement manually. A long press does different things depending on the OS you're on, therefore applying a single type of action from the component would not be recommended. For example, on windows Phone, a long press open a Context Menu, not selection.
You can find different suggestions and example in the Xamarin Forums, here's just one example.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Hello Lance,
I'm a RadListView user, I found that the EnableItemOrder can do nothing to me, because I can't detect when is the ordering finished, it means I can reorder items by drag and drop, but I can't update anything after user dropped item to reorder items,
do you have any solution for this issue??
I felt worrying about it after I successfully bought the UI for Xamarin Forms.
Please help.
Thank you!
Since you have a license, you can open a support ticket here. This will allow me (or anyone else from the UI for Xamarin engineering team) to work with you a little more closely. A support ticket carries a guaranteed response time as well.
Pertaining to the question itself, you can either use the SelectionChanged event or use the ListView's bound ObservableCollection.CollectionChanged event to see exactly what is occurring via the NotifyCollectionChangedEventArgs.
As an example, here's a simple view model with a collection for the ListView ItemsSource. Notice the event handler for CollectionChanged. You can see what exactly happens to an item under each Action condition:
public
class
ViewModel
{
public
ViewModel()
{
MyListViewItems.CollectionChanged += MyListViewItemsOnCollectionChanged;
}
public
ObservableCollection<MyItem> MyListViewItems {
get
;
set
; }
private
void
MyListViewItemsOnCollectionChanged(
object
sender, NotifyCollectionChangedEventArgs args)
{
switch
(args.Action)
{
case
NotifyCollectionChangedAction.Add:
break
;
case
NotifyCollectionChangedAction.Move:
break
;
case
NotifyCollectionChangedAction.Remove:
break
;
case
NotifyCollectionChangedAction.Replace:
break
;
case
NotifyCollectionChangedAction.Reset:
break
;
default
:
throw
new
ArgumentOutOfRangeException();
}
}
}
Additionally in you can see what items were part of that action via the args other properties:
case
NotifyCollectionChangedAction.Move:
var x = args.NewItems;
var y = args.NewStartingIndex;
Lastly, if you're not using MVVM and want to do this in the code-behind, the RadListView.SelectionChanged event also uses NotifyCollectionChangedEventArgs, so you can use the same approach as above.
If you have any further trouble, open a support ticket, attach your problematic code and we'll dig deeper.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Lance,
You are time saver! Apologize for my rude comment above, you solved my big problem and save a lot of time with it.
Thank you!