use a command instead of bool
MODIFY
WalletWasabi.Fluent/Behaviors/SplitViewAutoBehavior.cs
WalletWasabi.Fluent/Behaviors/SplitViewAutoBehavior.cs
@@ -16,8 +16,8 @@ namespace WalletWasabi.Fluent.Behaviors
public static readonly StyledProperty<double> CollapseThresholdProperty =
AvaloniaProperty.Register<SplitViewAutoBehavior, double>(nameof(CollapseThreshold));
- public static readonly StyledProperty<bool> IsExpandedProperty =
- AvaloniaProperty.Register<SplitViewAutoBehavior, bool>(nameof(IsExpanded), true);
+ public static readonly StyledProperty<Action> ToggleActionProperty =
+ AvaloniaProperty.Register<SplitViewAutoBehavior, Action>(nameof(ToggleAction));
public double CollapseThreshold
{
@@ -25,10 +25,10 @@ namespace WalletWasabi.Fluent.Behaviors
set => SetValue(CollapseThresholdProperty, value);
}
- public bool IsExpanded
+ public Action ToggleAction
{
- get => GetValue(IsExpandedProperty);
- set => SetValue(IsExpandedProperty, value);
+ get => GetValue(ToggleActionProperty);
+ set => SetValue(ToggleActionProperty, value);
}
protected override void OnAttached()
@@ -39,13 +39,14 @@ namespace WalletWasabi.Fluent.Behaviors
.DistinctUntilChanged()
.Subscribe(SplitViewBoundsChanged));
- Disposables.Add(this.GetObservable(IsExpandedProperty).Subscribe(OnIsExpandedChanged));
+ ToggleAction = OnToggleAction;
base.OnAttached();
}
- private void OnIsExpandedChanged(bool x)
+
+ private void OnToggleAction()
{
- AssociatedObject.IsPaneOpen = x;
+
}
private void SplitViewBoundsChanged(Rect x)
@@ -67,7 +68,7 @@ namespace WalletWasabi.Fluent.Behaviors
else
{
AssociatedObject.DisplayMode = SplitViewDisplayMode.CompactInline;
- AssociatedObject.IsPaneOpen = IsExpanded;
+ // AssociatedObject.IsPaneOpen = ToggleAction;
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBarViewModel.cs
@@ -20,7 +20,7 @@ namespace WalletWasabi.Fluent.ViewModels
private Dictionary<Wallet, WalletViewModelBase> _walletDictionary;
private bool _anyWalletStarted;
private bool _isBackButtonVisible;
- private bool _isExpanded = true;
+ private Action _toggleAction;
private IScreen _screen;
private bool _isNavigating;
@@ -107,6 +107,11 @@ namespace WalletWasabi.Fluent.ViewModels
});
}
+ public void DoToggleAction()
+ {
+ ToggleAction?.Invoke();
+ }
+
public ReactiveCommand<Unit, IRoutableViewModel> GoNext { get; }
public ReactiveCommand<Unit, Unit> GoBack => Router.NavigateBack;
@@ -163,10 +168,10 @@ namespace WalletWasabi.Fluent.ViewModels
}
}
- public bool IsExpanded
+ public Action ToggleAction
{
- get { return _isExpanded; }
- set { this.RaiseAndSetIfChanged(ref _isExpanded, value); }
+ get { return _toggleAction; }
+ set { this.RaiseAndSetIfChanged(ref _toggleAction, value); }
}
public bool IsBackButtonVisible

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
x:Class="WalletWasabi.Fluent.Views.MainView" TextBlock.Foreground="#A3A3A3">
<SplitView>
<i:Interaction.Behaviors>
- <behaviors:SplitViewAutoBehavior IsExpanded="{Binding NavBar.IsExpanded, Mode=TwoWay}" CollapseThreshold="{StaticResource SplitViewCollapseThreshold}"/>
+ <behaviors:SplitViewAutoBehavior ToggleAction="{Binding NavBar.ToggleAction, Mode=OneWayToSource}" CollapseThreshold="{StaticResource SplitViewCollapseThreshold}"/>
</i:Interaction.Behaviors>
<SplitView.Pane>
<Panel>

MODIFY
WalletWasabi.Fluent/Views/NavBar.axaml
WalletWasabi.Fluent/Views/NavBar.axaml
</StackPanel>
<StackPanel DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal" Spacing="5">
- <ToggleButton Classes="NavButton" IsChecked="{Binding IsExpanded, Mode=TwoWay}">
+ <Button Classes="NavButton" Command="{Binding DoToggleAction}">
<PathIcon Data="{StaticResource navigation_regular}" />
- </ToggleButton>
+ </Button>
<TextBlock Text="Wasabi Wallet" FontWeight="Bold" Foreground="White" VerticalAlignment="Center"/>
</StackPanel>
<ListBox Items="{Binding TopItems}" SelectedItem="{Binding SelectedItem}" />

use a command instead of bool