Skip to content

Instantly share code, notes, and snippets.

@sachintha81
Created January 13, 2017 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachintha81/5efffbcd21b86e9aef3fa1771f218a55 to your computer and use it in GitHub Desktop.
Save sachintha81/5efffbcd21b86e9aef3fa1771f218a55 to your computer and use it in GitHub Desktop.
WPF + C# Move Multiple Items from one ListView to Another
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace ListViewOperations.SOURCE.GUI
{
public partial class ListViewOperations : Window
{
/// <summary>
/// Moves selected item(s) between ListView controls.
/// </summary>
/// <param name=""from"">Moves from ListView</param>
/// <param name=""to"">Moves to ListView</param>
private void MoveListViewItems(ListView from, ListView to)
{
if (from.HasItems && from.SelectedItems != null)
{
var selected = from.SelectedItems.Cast<Object>().ToList();
foreach (var item in selected)
{
to.Items.Add(item.ToString());
from.Items.Remove(item);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment