Created
January 13, 2017 21:26
-
-
Save sachintha81/5efffbcd21b86e9aef3fa1771f218a55 to your computer and use it in GitHub Desktop.
WPF + C# Move Multiple Items from one ListView to Another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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