Dropdown visibility fixes
ADD
WalletWasabi.Fluent/Behaviors/PointerPressTriggerBehavior.cs
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Xaml.Interactivity;
+
+namespace WalletWasabi.Fluent.Behaviors;
+
+public class PointerPressTriggerBehavior : Trigger<Control>
+{
+ private KeyModifiers _savedKeyModifiers = KeyModifiers.None;
+
+ /// <summary>
+ /// Identifies the <seealso cref="KeyModifiers"/> avalonia property.
+ /// </summary>
+ public static readonly StyledProperty<KeyModifiers> KeyModifiersProperty =
+ AvaloniaProperty.Register<PointerPressTriggerBehavior, KeyModifiers>(nameof(KeyModifiers));
+
+ /// <summary>
+ /// Gets or sets the required key modifiers to execute <see cref="Button.ClickEvent"/> event handler. This is a avalonia property.
+ /// </summary>
+ public KeyModifiers KeyModifiers
+ {
+ get => GetValue(KeyModifiersProperty);
+ set => SetValue(KeyModifiersProperty, value);
+ }
+
+ /// <summary>
+ /// Called after the behavior is attached to the <see cref="Behavior.AssociatedObject"/>.
+ /// </summary>
+ protected override void OnAttached()
+ {
+ base.OnAttached();
+
+ if (AssociatedObject is { })
+ {
+ AssociatedObject.AddHandler(InputElement.PointerPressedEvent, PointerPressedHandler, RoutingStrategies.Tunnel);
+ }
+ }
+
+ /// <summary>
+ /// Called when the behavior is being detached from its <see cref="Behavior.AssociatedObject"/>.
+ /// </summary>
+ protected override void OnDetaching()
+ {
+ base.OnDetaching();
+
+ if (AssociatedObject is { })
+ {
+ AssociatedObject.RemoveHandler(InputElement.PointerPressedEvent, PointerPressedHandler);
+ }
+ }
+
+ private void AssociatedObject_OnClick(object? sender, RoutedEventArgs e)
+ {
+ if (AssociatedObject is { } && KeyModifiers == _savedKeyModifiers)
+ {
+ Interaction.ExecuteActions(AssociatedObject, Actions, e);
+ }
+ }
+
+ private void PointerPressedHandler(object? sender, PointerPressedEventArgs e)
+ {
+ Interaction.ExecuteActions(AssociatedObject, Actions, e);
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:navbar="using:WalletWasabi.Fluent.Views.NavBar"
- xmlns:i="using:Avalonia.Xaml.Interactivity"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
xmlns:behaviors="using:WalletWasabi.Fluent.Behaviors"
xmlns:ext="using:WalletWasabi.Fluent.Helpers"
xmlns:vm="using:WalletWasabi.Fluent.ViewModels"
xmlns:spectrum="clr-namespace:WalletWasabi.Fluent.Controls.Spectrum"
xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters"
xmlns:searchBar="clr-namespace:WalletWasabi.Fluent.Views.SearchBar"
+ xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="459"
x:DataType="vm:MainViewModel"
x:CompileBindings="True"
</Panel>
</Border>
+ <Border x:Name="SearchDropDownDismissArea" Background="Transparent" Grid.RowSpan="2" Grid.ColumnSpan="3" IsVisible="False">
+ <i:Interaction.Behaviors>
+ <ia:EventTriggerBehavior EventName="PointerPressed">
+ <ia:ChangePropertyAction TargetObject="{Binding #SearchBarDropdown}" PropertyName="IsVisible" Value="False" />
+ <ia:ChangePropertyAction TargetObject="{Binding #SearchDropDownDismissArea}" PropertyName="IsVisible" Value="False" />
+ </ia:EventTriggerBehavior>
+ </i:Interaction.Behaviors>
+ </Border>
<searchBar:SearchBar x:Name="SearchBar" VerticalAlignment="Center" DataContext="{Binding SearchBar}" Grid.Column="1"
- HorizontalAlignment="Center" Width="250" />
- <searchBar:SearchBarDropdown Width="400" MaxHeight="500" VerticalAlignment="Top" IsVisible="{Binding #SearchBar.IsKeyboardFocusWithin}" Grid.Row="1"
- Grid.Column="1" DataContext="{Binding SearchBar}" />
+ HorizontalAlignment="Center" Width="280">
+ <i:Interaction.Behaviors>
+ <behaviors:PointerPressTriggerBehavior>
+ <ia:ChangePropertyAction TargetObject="{Binding #SearchBarDropdown}" PropertyName="IsVisible" Value="True" />
+ <ia:ChangePropertyAction TargetObject="{Binding #SearchDropDownDismissArea}" PropertyName="IsVisible" Value="True" />
+ </behaviors:PointerPressTriggerBehavior>
+ </i:Interaction.Behaviors>
+ </searchBar:SearchBar>
+ <searchBar:SearchBarDropdown x:Name="SearchBarDropdown" Width="500" MaxHeight="500" VerticalAlignment="Top" IsVisible="False" Grid.Row="1"
+ Grid.Column="1" DataContext="{Binding SearchBar}">
+
+ </searchBar:SearchBarDropdown>
</Grid>
</Panel>
<ExperimentalAcrylicBorder DockPanel.Dock="Left" IsHitTestVisible="False"

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
x:Class="WalletWasabi.Fluent.Views.SearchBar.SearchBarDropdown"
xmlns:searchBar="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBarTextPart"
x:CompileBindings="False"
+ x:Name="UserControl"
x:DataType="searchBar:SearchBarViewModel"
xmlns:conv="clr-namespace:WalletWasabi.Fluent.Converters" Background="{StaticResource SystemBaseLowColor}">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="searchBar:SearchItem">
- <Button Background="Transparent" Command="{Binding Command}">
<DockPanel Background="Transparent">
<DockPanel.Children>
<TextBlock Margin="10 0" VerticalAlignment="Center" DockPanel.Dock="Left" Text="{Binding Name}" />
<TextBlock FontWeight="ExtraLight" VerticalAlignment="Center" Text="{Binding Description}" />
</DockPanel.Children>
+
+ <i:Interaction.Behaviors>
+ <EventTriggerBehavior EventName="PointerPressed">
+ <ia:InvokeCommandAction Command="{Binding Command}" />
+ </EventTriggerBehavior>
+ <EventTriggerBehavior EventName="PointerReleased">
+ <ChangePropertyAction TargetObject="{Binding #UserControl}" PropertyName="IsVisible" Value="False" />
+ </EventTriggerBehavior>
+ </i:Interaction.Behaviors>
+
</DockPanel>
- </Button>
+
</DataTemplate>
</ListBox.ItemTemplate>

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml
mc:Ignorable="d"
x:Class="WalletWasabi.Fluent.Views.SearchBar.SearchBar"
xmlns:searchBar="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBarTextPart"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
x:Name="UserControl">
<Design.DataContext>
</Style>
</UserControl.Styles>
- <TextBox x:Name="SearchBox" Watermark="Search for settings and advanced features" Text="{Binding SearchText, Mode=TwoWay}" />
+ <TextBox x:Name="SearchBox" Watermark="Search settings / advanced features" Text="{Binding SearchText, Mode=TwoWay}" />
</UserControl>
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml.cs
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml.cs
using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace WalletWasabi.Fluent.Views.SearchBar;
@@ -10,6 +12,11 @@ public class SearchBar : UserControl
InitializeComponent();
}
+ private void RootPointerPressed(object? sender, PointerPressedEventArgs e)
+ {
+ e.Handled = false;
+ }
+
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);

Dropdown visibility fixes