Inheritance: System.ComponentModel.PropertyChangedBase
        public SortViewModel(ICollectionView source, SortData[] columns, IEnumerable<SortDescription> existing = null,
            SortData[] requiredColumns = null) {
            View = source;
            Columns = columns;
            _requiredColumns = requiredColumns ?? new SortData[0];
            if (existing != null) {
                var d = View.DeferRefresh();
                SortDescriptions.Clear();
                foreach (var c in _requiredColumns)
                    SortDescriptions.Add(c.ToSortDescription());
                var item = existing
                    .FirstOrDefault(x => Columns.Select(y => y.Value).Contains(x.PropertyName));
                if (item != default(SortDescription)) {
                    SelectedSort = Columns.First(x => x.Value == item.PropertyName);
                    SelectedSort.SortDirection = item.Direction;
                    SortDescriptions.Add(item);
                }

                d.Dispose();
            } else {
                var item = SortDescriptions.FirstOrDefault(x => Columns.Select(y => y.Value).Contains(x.PropertyName));
                if (item != default(SortDescription)) {
                    SelectedSort = Columns.First(x => x.Value == item.PropertyName);
                    SelectedSort.SortDirection = item.Direction;
                }
            }

            OldSelectedSort = SelectedSort;

            this.WhenAnyValue(x => x.SelectedSort)
                .Skip(1)
                .Subscribe(x => SortColumn());
            this.SetCommand(x => x.SortCommand).Subscribe(x => SortColumn());
            this.SetCommand(x => x.ToggleVisibilityCommand).Subscribe(x => ToggleVisibility());
        }
 public void SetSort(string value) {
     UiHelper.TryOnUiThread(() => { SelectedSort = Columns.First(x => x.Value == value); });
 }
Esempio n. 3
0
 public void SetSort(string value)
 {
     UiHelper.TryOnUiThread(() => { SelectedSort = Columns.First(x => x.Value == value); });
 }