Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView
Effect for the Xamarin.Forms.ListView to make items reorderable
https://github.com/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView
Last synced: 3 months ago
JSON representation
Effect for the Xamarin.Forms.ListView to make items reorderable
- Host: GitHub
- URL: https://github.com/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView
- Owner: MintPlayer-Archive
- Archived: true
- Created: 2020-10-18T18:31:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T12:18:07.000Z (about 4 years ago)
- Last Synced: 2024-08-03T23:24:27.434Z (3 months ago)
- Language: C#
- Size: 842 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-xamarin-forms - SortableListView
README
# MintPlayer.Xamarin.Forms.SortableListView
[![NuGet Version](https://img.shields.io/nuget/v/MintPlayer.Xamarin.Forms.SortableListView.svg?style=flat)](https://www.nuget.org/packages/MintPlayer.Xamarin.Forms.SortableListView)
[![NuGet](https://img.shields.io/nuget/dt/MintPlayer.Xamarin.Forms.SortableListView.svg?style=flat)](https://www.nuget.org/packages/MintPlayer.Xamarin.Forms.SortableListView)
[![Build Status](https://travis-ci.org/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView.svg?branch=master)](https://travis-ci.org/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView)
![.NET Core](https://github.com/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView/workflows/.NET%20Core/badge.svg)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b7c01f2a24624a1585b8efe0bbe17954)](https://www.codacy.com/gh/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView/dashboard?utm_source=github.com&utm_medium=referral&utm_content=MintPlayer/MintPlayer.Xamarin.Forms.SortableListView&utm_campaign=Badge_Grade)This project contains an Effect for the Xamarin.Forms.ListView to make items reorderable
## Installation
### NuGet package manager
Open the NuGet package manager and install `MintPlayer.Xamarin.Forms.SortableListView` in your Xamarin.Forms project. It's not necessary to install the package in the platform projects.
### Package manager console
Install-Package MintPlayer.Xamarin.Forms.SortableListView## Usage
### Requirements
Currently, your android project must target Android 10 (Q) in order for the effect to work.
### Simple
Apply the effect on a Xamarin.Forms.ListView
### Advanced example
#### MainPage.xaml
Hold down an item for 1 second, in order to move it around.
Here the effect is attached to the ListView.
#### BaseModel.cs
public class BaseModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}protected bool SetProperty(ref T backingStore, T value, [CallerMemberName] string propertyName = "", Action onChanged = null)
{
if (EqualityComparer.Default.Equals(backingStore, value))
{
return false;
}backingStore = value;
onChanged?.Invoke();
OnPropertyChanged(propertyName);
return true;
}
}MainVM.cs
public class MainVM : BaseModel
{
public MainVM()
{
LoadPlayersCommand = new Command(OnLoadPlayers);
}#region Players
private ObservableCollection players = new ObservableCollection();
public ObservableCollection Players
{
get => players;
set => SetProperty(ref players, value);
}
#endregion
#region AllowReordering
private bool allowReordering = true;
public bool AllowReordering
{
get => allowReordering;
set => SetProperty(ref allowReordering, value);
}
#endregionpublic ICommand LoadPlayersCommand { get; }
private void OnLoadPlayers(object obj)
{
var players = PlayerService.GetPlayers();
foreach (var player in players)
this.players.Add(player);
}
}A complete example is available in this repository.