Put ToggleQrCode into AddressViewModel
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabView.xaml
<Setter Property="Padding" Value="0 0 5 0" />
</Style>
</controls:ExtendedListBox.Styles>
- <controls:ExtendedListBox.ContextMenu>
+ <controls:ExtendedListBox.ItemTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.ContextMenu>
<ContextMenu>
- <MenuItem Header="{Binding SelectedAddress.ExpandMenuCaption}" Command="{Binding ToggleQrCode}">
+ <MenuItem Header="{Binding ExpandMenuCaption}" Command="{Binding ToggleQrCode}">
<MenuItem.Icon>
<DrawingPresenter HorizontalAlignment="Left" Height="16" Width="16" Stretch="Fill" Drawing="{StaticResource ReceiveTabView_ToggleQrCode}" />
</MenuItem.Icon>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
- </controls:ExtendedListBox.ContextMenu>
- <controls:ExtendedListBox.ItemTemplate>
- <DataTemplate>
- <Grid>
+ </Grid.ContextMenu>
<Expander Name="coinExpander" ExpandDirection="Down" IsExpanded="{Binding IsExpanded}" Classes="coloredExpander" Background="{Binding ElementName=coinExpander, Path=IsExpanded, Converter={StaticResource CoinItemExpanderColorConverter}}">
<StackPanel Orientation="Horizontal" Spacing="16" Margin="35 10 0 5">
<controls:QrCode Height="220" Matrix="{Binding QrCode}" SaveCommand="{Binding ExecuteSaveQRCodeCommand, Mode=OneWayToSource}" HorizontalAlignment="Left" />

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -31,7 +31,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public ReactiveCommand<Unit, Unit> CopyAddress { get; }
public ReactiveCommand<Unit, Unit> CopyLabel { get; }
- public ReactiveCommand<Unit, Unit> ToggleQrCode { get; }
public ReactiveCommand<Unit, Unit> ChangeLabelCommand { get; }
public ReactiveCommand<Unit, Unit> DisplayAddressOnHwCommand { get; }
public ReactiveCommand<Unit, Unit> GenerateCommand { get; }
@@ -97,17 +96,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
CopyLabel = ReactiveCommand.CreateFromTask(async () => await Application.Current.Clipboard.SetTextAsync(SelectedAddress?.Label ?? string.Empty));
- ToggleQrCode = ReactiveCommand.Create(() =>
- {
- var selectedAddress = SelectedAddress;
- if (selectedAddress is null)
- {
- return;
- }
-
- selectedAddress.IsExpanded = !selectedAddress.IsExpanded;
- });
-
ChangeLabelCommand = ReactiveCommand.Create(() =>
{
var selectedAddress = SelectedAddress;
@@ -154,7 +142,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Observable
.Merge(DisplayAddressOnHwCommand.ThrownExceptions)
.Merge(ChangeLabelCommand.ThrownExceptions)
- .Merge(ToggleQrCode.ThrownExceptions)
.Merge(CopyAddress.ThrownExceptions)
.Merge(CopyLabel.ThrownExceptions)
.Merge(GenerateCommand.ThrownExceptions)

MODIFY
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
WalletWasabi.Gui/ViewModels/AddressViewModel.cs
@@ -10,6 +10,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Keys;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
namespace WalletWasabi.Gui.ViewModels
@@ -25,6 +26,7 @@ namespace WalletWasabi.Gui.ViewModels
private string _label;
private bool _inEditMode;
private ObservableAsPropertyHelper<string> _expandMenuCaption;
+ public ReactiveCommand<Unit, bool> ToggleQrCode { get; }
public HdPubKey Model { get; }
public Global Global { get; }
@@ -82,6 +84,16 @@ namespace WalletWasabi.Gui.ViewModels
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, x => x.ExpandMenuCaption)
.DisposeWith(Disposables);
+
+ ToggleQrCode = ReactiveCommand.Create(() => IsExpanded = !IsExpanded);
+
+ Observable
+ .Merge(ToggleQrCode.ThrownExceptions)
+ .Subscribe(ex =>
+ {
+ NotificationHelpers.Error(ex.ToTypeMessageString());
+ Logger.LogWarning(ex);
+ });
}
public bool IsLurkingWifeMode => Global.UiConfig.LurkingWifeMode is true;

Put ToggleQrCode into AddressViewModel