https://github.com/MintPlayer-Archive/MintPlayer.Xamarin.Forms.SortableListView
Effect for the Xamarin.Forms.ListView to make items reorderable
https://github.com/MintPlayer-Archive/MintPlayer.Xamarin.Forms.SortableListView
Last synced: 2 days ago
JSON representation
Effect for the Xamarin.Forms.ListView to make items reorderable
- Host: GitHub
- URL: https://github.com/MintPlayer-Archive/MintPlayer.Xamarin.Forms.SortableListView
- Owner: MintPlayer-Archive
- Archived: true
- Created: 2020-10-18T18:31:33.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-28T12:18:07.000Z (over 4 years ago)
- Last Synced: 2025-04-12T05:18:34.580Z (27 days ago)
- Language: C#
- Size: 842 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-xamarin-forms - SortableListView
README
# MintPlayer.Xamarin.Forms.SortableListView
[](https://www.nuget.org/packages/MintPlayer.Xamarin.Forms.SortableListView)
[](https://www.nuget.org/packages/MintPlayer.Xamarin.Forms.SortableListView)
[](https://travis-ci.org/MintPlayer/MintPlayer.Xamarin.Forms.SortableListView)

[](https://opensource.org/licenses/Apache-2.0)
[](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.