Use Observable
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/SendControlView.xaml
</i:Interaction.Behaviors>
</controls:ExtendedTextBox>
- <controls:ExtendedTextBox IsEnabled="{Binding !IsMax}" IsVisible="{Binding IsCustomChangeAddress}" Classes="monospaceFont" Text="{Binding CustomChangeAddress}" Watermark="(Optional) Custom Change Address" UseFloatingWatermark="True">
+ <controls:ExtendedTextBox IsEnabled="{Binding !IsMax}" IsVisible="{Binding IsCustomChangeAddressVisible}" Classes="monospaceFont" Text="{Binding CustomChangeAddress}" Watermark="(Optional) Custom Change Address" UseFloatingWatermark="True">
<i:Interaction.Behaviors>
<behaviors:PasteAddressOnClickBehavior />
</i:Interaction.Behaviors>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -58,7 +58,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private bool _isBusy;
private bool _isHardwareBusy;
private bool _isCustomFee;
- private bool _isCustomChangeAddress;
private const string WaitingForHardwareWalletButtonTextString = "Waiting for Hardware Wallet...";
@@ -180,16 +179,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
SetFeesAndTexts();
LabelToolTip = "Spending whole coins does not generate change, thus labeling is unnecessary.";
-
- IsCustomChangeAddress = false;
}
else
{
AmountText = "0.0";
LabelToolTip = "Who can link this transaction to you? E.g.: \"Max, BitPay\"";
-
- IsCustomChangeAddress = Global.UiConfig.IsCustomChangeAddress;
}
this.RaisePropertyChanged(nameof(Address));
@@ -205,15 +200,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => this.RaisePropertyChanged(nameof(Address)));
- this.WhenAnyValue(x => x.IsCustomChangeAddress)
+ this.WhenAnyValue(x => x.IsCustomChangeAddressVisible)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ =>
{
- if (IsMax)
- {
- IsCustomChangeAddress = false;
- }
-
this.RaisePropertyChanged(nameof(Address));
this.RaisePropertyChanged(nameof(CustomChangeAddress));
});
@@ -595,11 +585,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private set => this.RaiseAndSetIfChanged(ref _isCustomFee, value);
}
- public bool IsCustomChangeAddress
- {
- get => _isCustomChangeAddress;
- private set => this.RaiseAndSetIfChanged(ref _isCustomChangeAddress, value);
- }
+ public bool IsCustomChangeAddressVisible => Global.UiConfig.IsCustomChangeAddress && !IsMax;
public ReactiveCommand<Unit, Unit> BuildTransactionCommand { get; }
@@ -886,7 +872,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- if (Address == CustomChangeAddress && !IsMax && IsCustomChangeAddress)
+ if (Address == CustomChangeAddress && !IsMax && IsCustomChangeAddressVisible)
{
errors.Add(ErrorSeverity.Error, "The active address and the change address cannot be the same.");
}
@@ -916,7 +902,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return;
}
- if (Address == CustomChangeAddress && IsCustomChangeAddress)
+ if (Address == CustomChangeAddress && IsCustomChangeAddressVisible)
{
errors.Add(ErrorSeverity.Error, "The active address and the change address cannot be the same.");
}
@@ -965,16 +951,18 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Subscribe(x => IsCustomFee = x)
.DisposeWith(disposables);
- Global.UiConfig.WhenAnyValue(x => x.IsCustomChangeAddress)
- .ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(x => IsCustomChangeAddress = x)
- .DisposeWith(disposables);
-
this.WhenAnyValue(x => x.IsCustomFee)
.Where(x => !x)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(_ => IsSliderFeeUsed = true);
+ Observable
+ .Merge(Global.UiConfig.WhenAnyValue(x => x.IsCustomChangeAddress))
+ .Merge(this.WhenAnyValue(x => x.IsMax))
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(_ => this.RaisePropertyChanged(nameof(IsCustomChangeAddressVisible)))
+ .DisposeWith(disposables);
+
base.OnOpen(disposables);
}

Use Observable