-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement item selection on HorizontalListView? #8
Comments
You can easily implement it with the |
Do you have any examples? |
Well as I said add a class ItemViewModel
{
public bool IsSelected { get; set; }
}
class ListViewModel
{
public ListViewModel()
{
ListTapCommand = new Command(OnListTap);
}
public ObservableCollection<ItemViewModel> Items { get; }
public ICommand ListTapCommand { get; }
public void OnListTap(ItemViewModel tappedItem)
{
// One and only one selectable element
foreach (var item in Items)
{
item.IsSelected = item == tappedItem;
}
// OR
// One or zero selectable element
foreach (var item in Items)
{
item.IsSelected = item == tappedItem ? !item.IsSelected : false;
}
// OR
// Multiple selection
tappedItem.IsSelected = !tappedItem.IsSelected;
}
} |
ah thank you. This helps us out a lot. |
I will leave this open since it could help others as well. |
Actually thanks for re-opening this. Just wanted to include a full code snippet for anyone in the future. Please correct me if my implementation is incorrect. ListPage.cs
ListPageViewModel.cs
MyListItemModel.cs
|
The Drag and Drop functionality is great, but why isn't there any SelectedItem property? Id say this is one of the most important properties of a ListView (apart from ItemSource).
The text was updated successfully, but these errors were encountered: