use derived list to keep the coin list in sync with the backend.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
@@ -4,63 +4,20 @@ using System.Text;
using WalletWasabi.Gui.ViewModels;
using ReactiveUI;
using System.Collections.ObjectModel;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public class CoinListViewModel : ViewModelBase
{
private ObservableCollection<CoinViewModel> _selectedCoins;
- private ObservableCollection<CoinViewModel> _coins;
+ private IEnumerable<CoinViewModel> _coins;
public CoinListViewModel()
{
SelectedCoins = new ObservableCollection<CoinViewModel>();
- Coins = new ObservableCollection<CoinViewModel>
- {
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- new CoinViewModel(this)
- {
- AmountBtc = "+0.002",
- Confirmed = true,
- IsSelected = false,
- Label = "TestLabel", PrivacyLevel = 7
- },
- };
+ Coins = Global.WalletService.Coins.CreateDerivedCollection(c => new CoinViewModel(this, c), c => !c.SpentOrCoinJoinInProcess, (first, second) => first.Amount.CompareTo(second.Amount), RxApp.MainThreadScheduler);
}
public ObservableCollection<CoinViewModel> SelectedCoins
@@ -69,7 +26,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set { this.RaiseAndSetIfChanged(ref _selectedCoins, value); }
}
- public ObservableCollection<CoinViewModel> Coins
+ public IEnumerable<CoinViewModel> Coins
{
get { return _coins; }
set { this.RaiseAndSetIfChanged(ref _coins, value); }

use derived list to keep the coin list in sync with the backend.