I have a ListView which contains data of type
class InfoItem
{
public string IP { get; set; }
public string MAC { get; set; }
public string HOST { get; set; }
}
Event handler PingCompletedCallback gets IPs in random way, so we can`t predict order of Ips. We need to Sort them. Im using this
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(new Action(() =>
{
lstNetworks.Items.Add(new InfoItem() { IP = e.Reply.Address.ToString(), MAC = macAdress, HOST = hostName });
lstNetworks.Items.SortDescriptions.Add(new SortDescription("IP", ListSortDirection.Ascending));
}));
}
and it is partially works, but the result looks like this
192.168.1.1 192.168.1.10 192.168.1.2 192.168.1.254 192.168.1.3 and so on...
How can we sort this ListView items in right way
192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.10 192.168.1.254
UPDATE. I tried to do like in that question:
List<InfoItem> list = new List<InfoItem>();
foreach (var item in lstNetworks.Items) {
list.Add(item as InfoItem);
}
List<InfoItem> list2 = new List<InfoItem>();
list2 = list.Select(Version.Parse).OrderBy(arg => arg).Select(arg => arg.ToString()).ToList();
but it gives me and exception The type arguments for method Select cannot be inferred from the usage.