Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.