Sort Complex List Argument Exception UWP C# XAML List Binding

My aim is to order a list and than to bind it to the itemsource of my Listbox.
I get the list from a json httpreq.:
In my Json class I added IComperable, take a look:

enter public class Item:IComparable<Item>
        public InventoryItem InventoryItem { get; set; }
        public double Price { get; set; }

        public int CompareTo(Item other)
            return this.Price.CompareTo(other.Price);


    public class RootObject
        public bool Success { get; set; }
        public object Error { get; set; }
        public double Price { get; set; }
        public string Username { get; set; }
        public List<Item> Items { get; set; }


On The Mainpage .cs i do this after the httpreq:

var test =  JsonConvert.DeserializeObject<Jsonformat.RootObject>(content);
test.Items.Sort();        Itemlist.ItemsSource= test;

And I get an argument Exception.
DONT OVERREAD THIS: Without calling the .Sort() function I dont get any exception and its working fine.

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.