Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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);
}
#endregion

public 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.