diff --git a/src/client/spark/Risk/Combo/ComboReportFuturesGrid.cs b/src/client/spark/Risk/Combo/ComboReportFuturesGrid.cs index 96ccffc51..1fd37e205 100644 --- a/src/client/spark/Risk/Combo/ComboReportFuturesGrid.cs +++ b/src/client/spark/Risk/Combo/ComboReportFuturesGrid.cs @@ -1,26 +1,30 @@ namespace mbts.analytics { using bts.api; - using bts.collections; + using bts.utils; using mbts.ui.controls; using mbts.ui.shell; using mbts.ui.utility; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; class ComboFuturesGrid : DisposableViewModelBase { - readonly ObservableCollection _raw_expirations = new(); - readonly ObservableSortedCollection _sorted_expirations = new(); + /// As is mirrored by , it must: + /// 1) always be sorted + /// 2) never contain duplicates (even when synchronizing with a new list of exps), + /// since each column corresponds to a single visual element, and visual elements + /// cannot exist twice in a visual tree (or in different visual trees, for that matter) + readonly ObservableCollection _expirations = new(); readonly ComboReportFutureRow _row = new(); ComboViewFormat _view_format; public ComboFuturesGrid() { - _sorted_expirations.AddRange(_raw_expirations); _dispose = Disposable.Create( ObservableAutoWrapper.connect( - _sorted_expirations, _sorted_expirations, columns, _column_factory)); + _expirations, _expirations, columns, _column_factory)); } public ObservableCollection columns { get; } = new(); @@ -40,7 +44,7 @@ namespace mbts.analytics { .Select(vse => vse.expiration) .Distinct() .Select(exp_date => new VolSurfaceExpiration(string.Empty, exp_date)); - _raw_expirations.sync_with_setwise(data.future_expirations.Concat(exp_agg_cols)); + CollectionHelper.sync_with_never_duplicate(_expirations, exp_agg_cols.Ordered()); _row.update(data.get_future_exp_date_map()); } @@ -55,5 +59,4 @@ namespace mbts.analytics { return new ComboReportSymbolColumn(vse, Security.ContractOneofCase.Future, _view_format); } } - }