Move to user control
MODIFY
WalletWasabi.Fluent/Views/NavBar/NavBar.axaml
WalletWasabi.Fluent/Views/NavBar/NavBar.axaml
xmlns:c="using:WalletWasabi.Fluent.Controls"
xmlns:conv="using:WalletWasabi.Fluent.Converters"
xmlns:h="using:WalletWasabi.Fluent.Helpers"
- xmlns:rx="clr-namespace:System.Reactive;assembly=System.Reactive"
- 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="clr-namespace:WalletWasabi.Fluent.Behaviors;assembly=WalletWasabi.Fluent"
+ xmlns:navbar="using:WalletWasabi.Fluent.Views.NavBar"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.NavBar.NavBar" UseLayoutRounding="False">
<UserControl.Styles>
<StackPanel DockPanel.Dock="Bottom">
<Separator />
<c:NavBarListBox Items="{Binding BottomItems}" SelectedItem="{Binding SelectedItem}" />
- <AutoCompleteBox x:Name="SearchAutoCompleteBox" DataContext="{Binding SearchPage}" Items="{Binding SearchItems}" FilterMode="ContainsOrdinal" Watermark="Search (Ctrl+Q)">
- <AutoCompleteBox.Styles>
- <Style Selector="AutoCompleteBox">
- <Setter Property="Margin" Value="12,6,12,6" />
- <Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
- </Style>
- <Style Selector="AutoCompleteBox /template/ Border#PART_SuggestionsContainer">
- <Setter Property="Padding" Value="0" />
- <Setter Property="BorderThickness" Value="0" />
- <Setter Property="CornerRadius" Value="0" />
- </Style>
- <Style Selector="AutoCompleteBox /template/ ListBox#PART_SelectingItemsControl">
- <Setter Property="Margin" Value="0" />
- </Style>
- <Style Selector="AutoCompleteBox /template/ ListBox#PART_SelectingItemsControl ListBoxItem">
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- <Setter Property="Padding" Value="0,0,0,0" />
- </Style>
- <Style Selector="AutoCompleteBox /template/ Popup#PART_Popup">
- <Setter Property="MaxWidth" Value="{Binding $parent[UserControl].Bounds.Width}" />
- <Setter Property="PlacementMode" Value="AnchorAndGravity" />
- <Setter Property="PlacementAnchor" Value="Top" />
- <Setter Property="PlacementGravity" Value="Top" />
- </Style>
- <Style Selector="AutoCompleteBox /template/ TextBox DataValidationErrors">
- <Setter Property="IsVisible" Value="False" />
- </Style>
- </AutoCompleteBox.Styles>
- <AutoCompleteBox.ItemTemplate>
- <DataTemplate>
- <Panel Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
- <i:Interaction.Behaviors>
- <ia:EventTriggerBehavior EventName="PointerPressed">
- <ia:InvokeCommandAction Command="{Binding OpenCommand}" CommandParameter="{x:Static rx:Unit.Default}" />
- </ia:EventTriggerBehavior>
- </i:Interaction.Behaviors>
- <Panel Width="45" Margin="12,0,0,0" HorizontalAlignment="Left" IsHitTestVisible="False">
- <PathIcon HorizontalAlignment="Left">
- <PathIcon.Data>
- <Binding Path="." Converter="{x:Static conv:SearchIconConverter.Instance}" />
- </PathIcon.Data>
- </PathIcon>
- </Panel>
- <TextBlock Text="{Binding Title}" Margin="35 0 0 0" Padding="12" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False" />
- </Panel>
- </DataTemplate>
- </AutoCompleteBox.ItemTemplate>
- </AutoCompleteBox>
+ <navbar:NavBarSearch DataContext="{Binding SearchPage}" />
</StackPanel>
<c:NavBarTreeView Items="{Binding Items}" SelectedItem="{Binding SelectedItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">

ADD
WalletWasabi.Fluent/Views/NavBar/NavBarSearch.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:conv="using:WalletWasabi.Fluent.Converters"
+ xmlns:rx="clr-namespace:System.Reactive;assembly=System.Reactive"
+ xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
+ xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="WalletWasabi.Fluent.Views.NavBar.NavBarSearch" UseLayoutRounding="False">
+ <UserControl.Styles>
+ <Style Selector="AutoCompleteBox">
+ <Setter Property="Margin" Value="12,6,12,6" />
+ <Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
+ </Style>
+ <Style Selector="AutoCompleteBox /template/ Border#PART_SuggestionsContainer">
+ <Setter Property="Padding" Value="0" />
+ <Setter Property="BorderThickness" Value="0" />
+ <Setter Property="CornerRadius" Value="0" />
+ </Style>
+ <Style Selector="AutoCompleteBox /template/ ListBox#PART_SelectingItemsControl">
+ <Setter Property="Margin" Value="0" />
+ </Style>
+ <Style Selector="AutoCompleteBox /template/ ListBox#PART_SelectingItemsControl ListBoxItem">
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+ <Setter Property="Padding" Value="0,0,0,0" />
+ </Style>
+ <Style Selector="AutoCompleteBox /template/ Popup#PART_Popup">
+ <Setter Property="MaxWidth" Value="{Binding $parent[UserControl].Bounds.Width}" />
+ <Setter Property="PlacementMode" Value="AnchorAndGravity" />
+ <Setter Property="PlacementAnchor" Value="Top" />
+ <Setter Property="PlacementGravity" Value="Top" />
+ </Style>
+ <Style Selector="AutoCompleteBox /template/ TextBox DataValidationErrors">
+ <Setter Property="IsVisible" Value="False" />
+ </Style>
+ </UserControl.Styles>
+ <AutoCompleteBox Items="{Binding SearchItems}" FilterMode="ContainsOrdinal" Watermark="Search (Ctrl+Q)">
+ <AutoCompleteBox.ItemTemplate>
+ <DataTemplate>
+ <Panel Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
+ <i:Interaction.Behaviors>
+ <ia:EventTriggerBehavior EventName="PointerPressed">
+ <ia:InvokeCommandAction Command="{Binding OpenCommand}" CommandParameter="{x:Static rx:Unit.Default}" />
+ </ia:EventTriggerBehavior>
+ </i:Interaction.Behaviors>
+ <Panel Width="45" Margin="12,0,0,0" HorizontalAlignment="Left" IsHitTestVisible="False">
+ <PathIcon HorizontalAlignment="Left">
+ <PathIcon.Data>
+ <Binding Path="." Converter="{x:Static conv:SearchIconConverter.Instance}" />
+ </PathIcon.Data>
+ </PathIcon>
+ </Panel>
+ <TextBlock Text="{Binding Title}" Margin="35 0 0 0" Padding="12" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="False" />
+ </Panel>
+ </DataTemplate>
+ </AutoCompleteBox.ItemTemplate>
+ </AutoCompleteBox>
+</UserControl>
\ No newline at end of file

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

Move to user control