예제 #1
0
        private void SearchHeader_OnSortChanged(object sender, EventArgs e)
        {
            var itemSource = filteredMuaData;

            switch (searchHeader.SearchSort)
            {
            case SearchSortType.Rating:
                itemSource = filteredMuaData.OrderByDescending(m => m.Rating);
                break;

            case SearchSortType.Nearest:
                var currPosition = Geolocator.Instance.LastKnowPosition;
                if (currPosition != null)
                {
                    itemSource = filteredMuaData.OrderBy(m => Geolocator.DistanceBetweenPlaces(
                                                             currPosition.Longitude, currPosition.Latitude, m.LocationLon, m.LocationLat));
                }
                break;

            case SearchSortType.LowestPrice:
                itemSource = filteredMuaData.OrderBy(m => m.PriceMin);
                break;

            case SearchSortType.HighestPrice:
                itemSource = filteredMuaData.OrderByDescending(m => m.PriceMax);
                break;
            }
            muaList.ItemsSource = itemSource;
        }