Create unified control
MODIFY
WalletWasabi.Fluent/ViewModels/SearchBar/SearchBarDesignViewModel.cs
WalletWasabi.Fluent/ViewModels/SearchBar/SearchBarDesignViewModel.cs
@@ -38,5 +38,5 @@ public class SearchBarDesignViewModel : ReactiveObject
return new SearchItemGroup(g.Key, sourceCache);
})));
- public string SearchText => "Sample text";
+ public string SearchText => "";
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/MainView.axaml
WalletWasabi.Fluent/Views/MainView.axaml
</ic:RoutedEventTriggerBehavior>
</i:Interaction.Behaviors>
</Border>
- <searchBar:SearchBar x:Name="SearchBar" VerticalAlignment="Center" DataContext="{Binding SearchBar}" Grid.Column="1"
+ <searchBar:SearchBarTextPart x:Name="SearchBar" VerticalAlignment="Center" DataContext="{Binding SearchBar}" Grid.Column="1"
HorizontalAlignment="Center" Width="280">
<i:Interaction.Behaviors>
<ic:RoutedEventTriggerBehavior RoutedEvent="{x:Static InputElement.PointerPressedEvent}" RoutingStrategies="Tunnel">
<ia:ChangePropertyAction TargetObject="SearchDropDownDismissArea" PropertyName="IsVisible" Value="True" />
</ic:RoutedEventTriggerBehavior>
</i:Interaction.Behaviors>
- </searchBar:SearchBar>
+ </searchBar:SearchBarTextPart>
<searchBar:SearchBarDropdown x:Name="SearchBarDropdown" Width="500" MaxHeight="500" VerticalAlignment="Top" IsVisible="False" Grid.Row="1"
Grid.Column="1" DataContext="{Binding SearchBar}">

ADD
WalletWasabi.Fluent/Views/SearchBar/SearchBar.axaml
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:s="clr-namespace:WalletWasabi.Fluent.Views.SearchBar"
+ xmlns:searchBarTextPart="clr-namespace:WalletWasabi.Fluent.ViewModels.SearchBarTextPart"
+ mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
+ xmlns:ic="clr-namespace:Avalonia.Xaml.Interactions.Custom;assembly=Avalonia.Xaml.Interactions"
+ x:Class="WalletWasabi.Fluent.Views.SearchBar.SearchBar">
+
+ <Design.DataContext>
+ <searchBarTextPart:SearchBarDesignViewModel />
+ </Design.DataContext>
+
+ <Panel>
+ <Panel x:Name="DismissArea" Background="Transparent" IsVisible="False">
+ <i:Interaction.Behaviors>
+ <ic:RoutedEventTriggerBehavior RoutedEvent="{x:Static InputElement.PointerPressedEvent}">
+ <ia:ChangePropertyAction TargetObject="SearchBarDropdown" PropertyName="IsVisible" Value="False" />
+ <ia:ChangePropertyAction TargetObject="DismissArea" PropertyName="IsVisible" Value="False" />
+ </ic:RoutedEventTriggerBehavior>
+ </i:Interaction.Behaviors>
+ </Panel>
+ <StackPanel Margin="400 0" VerticalAlignment="Top">
+ <Panel Height="50">
+ <s:SearchBarTextPart HorizontalAlignment="Left" Margin="10" Width="240">
+ <i:Interaction.Behaviors>
+ <ic:RoutedEventTriggerBehavior RoutedEvent="{x:Static InputElement.PointerPressedEvent}"
+ RoutingStrategies="Tunnel">
+ <ia:ChangePropertyAction TargetObject="SearchBarDropdown" PropertyName="IsVisible" Value="True" />
+ <ia:ChangePropertyAction TargetObject="DismissArea" PropertyName="IsVisible" Value="True" />
+ </ic:RoutedEventTriggerBehavior>
+ </i:Interaction.Behaviors>
+ </s:SearchBarTextPart></Panel>
+ <s:SearchBarDropdown x:Name="SearchBarDropdown" IsVisible="False" HorizontalAlignment="Left" MinWidth="400" MaxHeight="500" />
+ </StackPanel>
+ </Panel>
+</UserControl>

ADD
WalletWasabi.Fluent/Views/SearchBar/SearchBar.axaml.cs
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace WalletWasabi.Fluent.Views.SearchBar;
+
+public class SearchBar : UserControl
+{
+ public SearchBar()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+}

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBarDropdown.axaml
</Design.DataContext>
<UserControl.Styles>
+
<Style Selector="ListBoxItem">
<Setter Property="Padding" Value="0" />
</Style>
+ <Style Selector="ItemsControl:empty">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <TextBlock Margin="10">No results</TextBlock>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
</UserControl.Styles>
<ScrollViewer>

MODIFY
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml
WalletWasabi.Fluent/Views/SearchBar/SearchBarTextPart.axaml
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
- x:Class="WalletWasabi.Fluent.Views.SearchBar.SearchBar"
+ x:Class="WalletWasabi.Fluent.Views.SearchBar.SearchBarTextPart"
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>
</UserControl.Resources>
<UserControl.Styles>
- <Style Selector="ItemsControl:empty">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate>
- <TextBlock Margin="10">No results</TextBlock>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
<Style Selector="TextBox#SearchBox">
<Setter Property="Background" Value="Transparent" />

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;
-public class SearchBar : UserControl
+public class SearchBarTextPart : UserControl
{
- public SearchBar()
+ public SearchBarTextPart()
{
InitializeComponent();
}

Create unified control