I wanted to implement the fisher-yates shuffle in wpf so I could shuffle the contents of a listview control by using a button click.
I found the follwing snippet of code but it is created for system.windows.forms.listview:
ListView.ListViewItemCollection list = listView1.Items;
Random rng = new Random();
int n = list.Count;
while (n > 1)
int k = rng.Next(n + 1);
ListViewItem value1 = (ListViewItem)list[k];
ListViewItem value2 = (ListViewItem)list[n];
list[k] = new ListViewItem();
list[n] = new ListViewItem();
list[k] = value2;
list[n] = value1;
Can I modify this snippet for use in WPF? If not, could you provide a suggestion for shuffling the contents of a listview control in wpf?
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)