Enable focusing Cancel/Next buttons in ContentArea
MODIFY
WalletWasabi.Fluent/Controls/ContentArea.axaml
WalletWasabi.Fluent/Controls/ContentArea.axaml
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls">
+ xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
+ xmlns:behaviors="clr-namespace:WalletWasabi.Fluent.Behaviors;assembly=WalletWasabi.Fluent"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity">
<Design.PreviewWith>
<Panel Background="{DynamicResource RegionColor}">
<c:ContentArea Width="500" Height="300"
Title="Add a Wallet"
EnableBack="True"
- EnableCancel="True" CancelContent="Cancel"
- EnableNext="True" NextContent="Continue"
+ EnableCancel="True" CancelContent="Cancel" FocusCancel="False"
+ EnableNext="True" NextContent="Continue" FocusNext="True"
Caption="Type in your Wallet's name and select an option below:">
This is the content.
</c:ContentArea>
<ContentPresenter Name="PART_CaptionPresenter" Content="{TemplateBinding Caption}" />
</StackPanel>
<Panel DockPanel.Dock="Bottom">
- <Button Name="PART_CancelButton" Classes="invisible" IsVisible="{TemplateBinding EnableCancel}" Content="{TemplateBinding CancelContent}" Margin="0,10,10,10" HorizontalAlignment="Left" Command="{Binding CancelCommand}" />
- <Button Name="PART_NextButton" Classes="action" IsVisible="{TemplateBinding EnableNext}" Content="{TemplateBinding NextContent}" Margin="10,10,0,10" HorizontalAlignment="Right" Command="{Binding NextCommand}" />
+ <Button Name="PART_CancelButton" Classes="invisible" IsVisible="{TemplateBinding EnableCancel}" Content="{TemplateBinding CancelContent}" Margin="0,10,10,10" HorizontalAlignment="Left" Command="{Binding CancelCommand}">
+ <i:Interaction.Behaviors>
+ <behaviors:FocusOnAttachedBehavior IsEnabled="{Binding FocusCancel}" />
+ </i:Interaction.Behaviors>
+ </Button>
+ <Button Name="PART_NextButton" Classes="action" IsVisible="{TemplateBinding EnableNext}" Content="{TemplateBinding NextContent}" Margin="10,10,0,10" HorizontalAlignment="Right" Command="{Binding NextCommand}">
+ <i:Interaction.Behaviors>
+ <behaviors:FocusOnAttachedBehavior IsEnabled="{Binding FocusNext}" />
+ </i:Interaction.Behaviors>
+ </Button>
</Panel>
<ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"

MODIFY
WalletWasabi.Fluent/Controls/ContentArea.axaml.cs
WalletWasabi.Fluent/Controls/ContentArea.axaml.cs
@@ -21,6 +21,12 @@ namespace WalletWasabi.Fluent.Controls
public static readonly StyledProperty<bool> EnableNextProperty =
AvaloniaProperty.Register<ContentArea, bool>(nameof(EnableNext));
+ public static readonly StyledProperty<bool> FocusNextProperty =
+ AvaloniaProperty.Register<ContentArea, bool>(nameof(FocusNext));
+
+ public static readonly StyledProperty<bool> FocusCancelProperty =
+ AvaloniaProperty.Register<ContentArea, bool>(nameof(FocusCancel));
+
public static readonly StyledProperty<object> CancelContentProperty =
AvaloniaProperty.Register<ContentArea, object>(nameof(CancelContent), "Cancel");
@@ -60,6 +66,18 @@ namespace WalletWasabi.Fluent.Controls
set => SetValue(EnableNextProperty, value);
}
+ public bool FocusNext
+ {
+ get => GetValue(FocusNextProperty);
+ set => SetValue(FocusNextProperty, value);
+ }
+
+ public bool FocusCancel
+ {
+ get => GetValue(FocusCancelProperty);
+ set => SetValue(FocusCancelProperty, value);
+ }
+
public object CancelContent
{
get => GetValue(CancelContentProperty);

Enable focusing Cancel/Next buttons in ContentArea