Add inline mouse-triggered search button in search field

This commit is contained in:
Meik
2026-03-05 14:05:25 +01:00
parent 95031a9ee4
commit 964ed2f018
3 changed files with 77 additions and 15 deletions

View File

@@ -70,6 +70,57 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SearchInlineButtonStyle"
TargetType="{x:Type Button}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Cursor"
Value="Hand" />
<Setter Property="Width"
Value="32" />
<Setter Property="Height"
Value="32" />
<Setter Property="Padding"
Value="0" />
<Setter Property="HorizontalAlignment"
Value="Right" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="Margin"
Value="0,0,4,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="InlineSearchBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="InlineSearchBorder"
Property="Background"
Value="{DynamicResource navigationHoverColor}" />
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Opacity"
Value="0.92" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="GridSsp"
@@ -107,25 +158,28 @@
VerticalContentAlignment="Center"
Padding="0"
Canvas.Left="40" />
<StackPanel Orientation="Horizontal"
Width="350"
Canvas.Top="56"
Canvas.Left="0">
<Grid Width="320"
Height="40"
Canvas.Top="56"
Canvas.Left="15">
<TextBox x:Name="TxtSearchTerm"
x:FieldModifier="private"
Style="{StaticResource SearchTextBoxStyle}"
Width="320"
Height="40"
Padding="8,3,42,3"
FontSize="14"
Panel.ZIndex="1110"
KeyDown="OnSearchBoxEnter"
Margin="2,0,0,0" />
<Image Source="../Resources/icons/light/appbar.magnify.png"
Width="48"
PreviewMouseDown="OnSearchClicked"
Cursor="Hand"
Visibility="Collapsed" />
</StackPanel>
KeyDown="OnSearchBoxEnter" />
<Button Style="{StaticResource SearchInlineButtonStyle}"
Click="OnSearchButtonClick"
ToolTip="{x:Static resx:Resources.search}">
<Image Source="{DynamicResource appbar_magnify}"
Width="18"
Height="18"
Tag="MAINICO" />
</Button>
</Grid>
<Canvas Canvas.Top="120"
Canvas.Left="0"
Width="350"