feat: Add SearchBar control, themes and demo.
This commit is contained in:
1 parent
aa32f72563
commit
550b980f54
6 files changed
+594
No files matched your search
@@ -47,6 +47,7 @@
|
|||||||
[ "ProgressButton", "ProgressButtonDemo", "Brush.ProgressBarStatusBar8", "", "Button" ],
|
[ "ProgressButton", "ProgressButtonDemo", "Brush.ProgressBarStatusBar8", "", "Button" ],
|
||||||
[ "Card", "CardDemo", "Brush.ContactCard", "", "DataDisplay" ],
|
[ "Card", "CardDemo", "Brush.ContactCard", "", "DataDisplay" ],
|
||||||
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
|
[ "PinBox", "PinBoxDemo", "Brush.Ellipsis", "", "DataEntry" ],
|
||||||
|
[ "SearchBar", "SearchBarDemo", "Brush.Search", "", "DataEntry" ],
|
||||||
[ "ElementGroup", "ElementGroupDemo", "Brush.ButtonGroup", "", "Layout" ],
|
[ "ElementGroup", "ElementGroupDemo", "Brush.ButtonGroup", "", "Layout" ],
|
||||||
[ "CirclePanel", "CirclePanelDemo", "Brush.ColorWheel", "", "Layout" ],
|
[ "CirclePanel", "CirclePanelDemo", "Brush.ColorWheel", "", "Layout" ],
|
||||||
[ "Grid", "GridDemo", "Brush.GridPane", "", "Layout" ],
|
[ "Grid", "GridDemo", "Brush.GridPane", "", "Layout" ],
|
||||||
|
|||||||
@@ -0,0 +1,144 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:vm="clr-namespace:HandyControlDemo.ViewModel"
|
||||||
|
x:Class="HandyControlDemo.UserControl.SearchBarDemo"
|
||||||
|
DataContext="{Binding InputElementDemo, Source={x:Static vm:ViewModelLocator.Instance}}"
|
||||||
|
Background="{DynamicResource RegionBrush}">
|
||||||
|
<TransitioningContentControl>
|
||||||
|
<ScrollViewer>
|
||||||
|
<hc:UniformSpacingPanel Spacing="32"
|
||||||
|
Margin="32"
|
||||||
|
ChildWrapping="Wrap">
|
||||||
|
<StackPanel Spacing="16">
|
||||||
|
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar IsEnabled="False" />
|
||||||
|
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend}"
|
||||||
|
hc:TitleElement.Title="This is the title"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted"
|
||||||
|
Margin="0,16,0,0" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend}"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Spacing="16">
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
hc:TitleElement.Title="This is the title"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
Watermark="please enter email"
|
||||||
|
Text="{Binding Email1, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus}"
|
||||||
|
Width="380"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Spacing="16">
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBar.Small}"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBar.Small}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend.Small}"
|
||||||
|
hc:TitleElement.Title="This is the title"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend.Small}"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend.Small}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarExtend.Small}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Spacing="16">
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
IsEnabled="False" />
|
||||||
|
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
hc:TitleElement.Title="This is the title"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
Watermark="please enter email"
|
||||||
|
Text="{Binding Email2, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
hc:TitleElement.Title="This item must be filled in"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
Width="380"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
<hc:SearchBar Theme="{StaticResource SearchBarPlus.Small}"
|
||||||
|
Width="380"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
hc:TitleElement.TitlePlacement="Left"
|
||||||
|
hc:TitleElement.Title="The title is on the left"
|
||||||
|
Watermark="Please enter content"
|
||||||
|
hc:InfoElement.Necessary="True"
|
||||||
|
SearchStarted="SearchBar_OnSearchStarted" />
|
||||||
|
</StackPanel>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</TransitioningContentControl>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using Avalonia.Interactivity;
|
||||||
|
using HandyControl.Controls;
|
||||||
|
using HandyControl.Data;
|
||||||
|
|
||||||
|
namespace HandyControlDemo.UserControl;
|
||||||
|
|
||||||
|
public partial class SearchBarDemo : Avalonia.Controls.UserControl
|
||||||
|
{
|
||||||
|
public SearchBarDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchBar_OnSearchStarted(object? sender, FunctionEventArgs<string?> e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(e.Info))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var growlType = System.Type.GetType("HandyControl.Controls.Growl, HandyControl");
|
||||||
|
var method = growlType?.GetMethod("Info", [typeof(string), typeof(string)]);
|
||||||
|
method?.Invoke(null, [e.Info, string.Empty]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Metadata;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using HandyControl.Data;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls;
|
||||||
|
|
||||||
|
[TemplatePart(Name = ElementSearchButton, Type = typeof(Button))]
|
||||||
|
public class SearchBar : TextBox
|
||||||
|
{
|
||||||
|
private const string ElementSearchButton = "PART_SearchButton";
|
||||||
|
|
||||||
|
public static readonly RoutedEvent<FunctionEventArgs<string?>> SearchStartedEvent =
|
||||||
|
RoutedEvent.Register<SearchBar, FunctionEventArgs<string?>>(nameof(SearchStarted), RoutingStrategies.Bubble);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> IsRealTimeProperty =
|
||||||
|
AvaloniaProperty.Register<SearchBar, bool>(nameof(IsRealTime));
|
||||||
|
|
||||||
|
public static readonly StyledProperty<ICommand?> CommandProperty =
|
||||||
|
AvaloniaProperty.Register<SearchBar, ICommand?>(nameof(Command));
|
||||||
|
|
||||||
|
public static readonly StyledProperty<object?> CommandParameterProperty =
|
||||||
|
AvaloniaProperty.Register<SearchBar, object?>(nameof(CommandParameter));
|
||||||
|
|
||||||
|
public static readonly StyledProperty<IInputElement?> CommandTargetProperty =
|
||||||
|
AvaloniaProperty.Register<SearchBar, IInputElement?>(nameof(CommandTarget));
|
||||||
|
|
||||||
|
private Button? _searchButton;
|
||||||
|
|
||||||
|
static SearchBar()
|
||||||
|
{
|
||||||
|
TextProperty.Changed.AddClassHandler<SearchBar>((searchBar, _) =>
|
||||||
|
{
|
||||||
|
if (searchBar.IsRealTime)
|
||||||
|
{
|
||||||
|
searchBar.OnSearchStarted();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler<FunctionEventArgs<string?>> SearchStarted
|
||||||
|
{
|
||||||
|
add => AddHandler(SearchStartedEvent, value);
|
||||||
|
remove => RemoveHandler(SearchStartedEvent, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRealTime
|
||||||
|
{
|
||||||
|
get => GetValue(IsRealTimeProperty);
|
||||||
|
set => SetValue(IsRealTimeProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand? Command
|
||||||
|
{
|
||||||
|
get => GetValue(CommandProperty);
|
||||||
|
set => SetValue(CommandProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object? CommandParameter
|
||||||
|
{
|
||||||
|
get => GetValue(CommandParameterProperty);
|
||||||
|
set => SetValue(CommandParameterProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInputElement? CommandTarget
|
||||||
|
{
|
||||||
|
get => GetValue(CommandTargetProperty);
|
||||||
|
set => SetValue(CommandTargetProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnApplyTemplate(e);
|
||||||
|
|
||||||
|
if (_searchButton != null)
|
||||||
|
{
|
||||||
|
_searchButton.Click -= SearchButtonOnClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
_searchButton = e.NameScope.Find<Button>(ElementSearchButton);
|
||||||
|
if (_searchButton != null)
|
||||||
|
{
|
||||||
|
_searchButton.Click += SearchButtonOnClick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnKeyDown(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnKeyDown(e);
|
||||||
|
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
OnSearchStarted();
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OnSearchStarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSearchStarted()
|
||||||
|
{
|
||||||
|
RaiseEvent(new FunctionEventArgs<string?>(SearchStartedEvent, this)
|
||||||
|
{
|
||||||
|
Info = Text
|
||||||
|
});
|
||||||
|
|
||||||
|
var command = Command;
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameter = CommandParameter ?? Text;
|
||||||
|
if (!command.CanExecute(parameter))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
command.Execute(parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/Clock.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/Clock.axaml" />
|
||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/TimePicker.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/TimePicker.axaml" />
|
||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/TextBox.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/TextBox.axaml" />
|
||||||
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/SearchBar.axaml" />
|
||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/PinBox.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/PinBox.axaml" />
|
||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/AutoCompleteBox.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/AutoCompleteBox.axaml" />
|
||||||
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/ButtonSpinner.axaml" />
|
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/ButtonSpinner.axaml" />
|
||||||
|
|||||||
@@ -0,0 +1,294 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:ClassModifier="internal"
|
||||||
|
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||||
|
xmlns:sys="using:System">
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBarBaseStyle"
|
||||||
|
BasedOn="{StaticResource TextBoxBaseStyle}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<DataValidationErrors>
|
||||||
|
<Panel>
|
||||||
|
<Border x:Name="border"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding Watermark}" />
|
||||||
|
<ScrollViewer Grid.Column="0"
|
||||||
|
Name="PART_ScrollViewer"
|
||||||
|
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||||
|
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||||
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
|
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||||
|
VerticalScrollBarVisibility="Hidden">
|
||||||
|
<TextPresenter Name="PART_TextPresenter"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||||
|
CaretBrush="{TemplateBinding CaretBrush}"
|
||||||
|
CaretIndex="{TemplateBinding CaretIndex}"
|
||||||
|
LineHeight="{TemplateBinding LineHeight}"
|
||||||
|
LetterSpacing="{TemplateBinding LetterSpacing}"
|
||||||
|
PasswordChar="{TemplateBinding PasswordChar}"
|
||||||
|
RevealPassword="{TemplateBinding RevealPassword}"
|
||||||
|
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||||
|
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||||
|
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||||
|
SelectionStart="{TemplateBinding SelectionStart}"
|
||||||
|
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||||
|
TextAlignment="{TemplateBinding TextAlignment}"
|
||||||
|
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
x:Name="PART_SearchButton"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Focusable="False"
|
||||||
|
Theme="{StaticResource ButtonIcon}"
|
||||||
|
hc:IconElement.Width="14"
|
||||||
|
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
|
||||||
|
hc:IconElement.Geometry="{StaticResource SearchGeometry}"
|
||||||
|
Foreground="{Binding BorderBrush, ElementName=border}" />
|
||||||
|
</Grid>
|
||||||
|
</Panel>
|
||||||
|
</DataValidationErrors>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^:disabled">
|
||||||
|
<Setter Property="Opacity"
|
||||||
|
Value="0.4" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:pointerover /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource SecondaryBorderBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Style Selector="^:pointerover /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:error /template/ Border#border">
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource DangerBrush}" />
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="{x:Type hc:SearchBar}"
|
||||||
|
BasedOn="{StaticResource SearchBarBaseStyle}"
|
||||||
|
TargetType="hc:SearchBar" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBar.Small"
|
||||||
|
BasedOn="{StaticResource SearchBarBaseStyle}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBarExtend"
|
||||||
|
BasedOn="{StaticResource SearchBarBaseStyle}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="hc:InfoElement.Symbol"
|
||||||
|
Value="●" />
|
||||||
|
<Setter Property="hc:InfoElement.ContentHeight"
|
||||||
|
Value="{x:Static sys:Double.NaN}" />
|
||||||
|
<Setter Property="hc:InfoElement.MinContentHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<HeaderedContentControl Header="{Binding $parent.(hc:TitleElement.Title)}">
|
||||||
|
<Grid ColumnDefinitions="*,Auto">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding Watermark}" />
|
||||||
|
<ScrollViewer Grid.Column="0"
|
||||||
|
Name="PART_ScrollViewer"
|
||||||
|
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||||
|
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||||
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
|
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||||
|
VerticalScrollBarVisibility="Hidden">
|
||||||
|
<TextPresenter Name="PART_TextPresenter"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||||
|
CaretBrush="{TemplateBinding CaretBrush}"
|
||||||
|
CaretIndex="{TemplateBinding CaretIndex}"
|
||||||
|
LineHeight="{TemplateBinding LineHeight}"
|
||||||
|
LetterSpacing="{TemplateBinding LetterSpacing}"
|
||||||
|
PasswordChar="{TemplateBinding PasswordChar}"
|
||||||
|
RevealPassword="{TemplateBinding RevealPassword}"
|
||||||
|
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||||
|
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||||
|
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||||
|
SelectionStart="{TemplateBinding SelectionStart}"
|
||||||
|
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||||
|
TextAlignment="{TemplateBinding TextAlignment}"
|
||||||
|
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
x:Name="PART_SearchButton"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Focusable="False"
|
||||||
|
Theme="{StaticResource ButtonIcon}"
|
||||||
|
hc:IconElement.Width="14"
|
||||||
|
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
|
||||||
|
hc:IconElement.Geometry="{StaticResource SearchGeometry}"
|
||||||
|
Foreground="{Binding BorderBrush, ElementName=border}" />
|
||||||
|
</Grid>
|
||||||
|
</HeaderedContentControl>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBarExtend.Small"
|
||||||
|
BasedOn="{StaticResource SearchBarExtend}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="hc:InfoElement.MinContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:InfoElement.ContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheLeft"
|
||||||
|
Value="0,3,6,0" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheTop"
|
||||||
|
Value="6,0,0,1" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBarPlus"
|
||||||
|
BasedOn="{StaticResource SearchBarExtend}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<HeaderedContentControl Header="{Binding $parent.(hc:TitleElement.Title)}">
|
||||||
|
<Grid ColumnDefinitions="*,Auto,Auto">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Grid.ColumnSpan="3"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}" />
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Theme="{StaticResource TextBlockDefaultThiLight}"
|
||||||
|
Text="{TemplateBinding Watermark}" />
|
||||||
|
<ScrollViewer Grid.Column="0"
|
||||||
|
Name="PART_ScrollViewer"
|
||||||
|
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||||
|
BringIntoViewOnFocusChange="{TemplateBinding (ScrollViewer.BringIntoViewOnFocusChange)}"
|
||||||
|
HorizontalScrollBarVisibility="Hidden"
|
||||||
|
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||||
|
VerticalScrollBarVisibility="Hidden">
|
||||||
|
<TextPresenter Name="PART_TextPresenter"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
CaretBlinkInterval="{TemplateBinding CaretBlinkInterval}"
|
||||||
|
CaretBrush="{TemplateBinding CaretBrush}"
|
||||||
|
CaretIndex="{TemplateBinding CaretIndex}"
|
||||||
|
LineHeight="{TemplateBinding LineHeight}"
|
||||||
|
LetterSpacing="{TemplateBinding LetterSpacing}"
|
||||||
|
PasswordChar="{TemplateBinding PasswordChar}"
|
||||||
|
RevealPassword="{TemplateBinding RevealPassword}"
|
||||||
|
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||||
|
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||||
|
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||||
|
SelectionStart="{TemplateBinding SelectionStart}"
|
||||||
|
Text="{TemplateBinding Text, Mode=TwoWay}"
|
||||||
|
TextAlignment="{TemplateBinding TextAlignment}"
|
||||||
|
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||||
|
</ScrollViewer>
|
||||||
|
<Button Grid.Column="1"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Focusable="False"
|
||||||
|
Theme="{StaticResource ButtonIcon}"
|
||||||
|
hc:IconElement.Width="14"
|
||||||
|
Padding="0,0,2,0"
|
||||||
|
hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
|
||||||
|
Foreground="{Binding BorderBrush, ElementName=border}"
|
||||||
|
Command="{Binding $parent[TextBox].Clear}">
|
||||||
|
<Button.IsVisible>
|
||||||
|
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}"
|
||||||
|
Path="IsPointerOver" />
|
||||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}"
|
||||||
|
Path="(hc:InfoElement.ShowClearButton)" />
|
||||||
|
<Binding RelativeSource="{RelativeSource TemplatedParent}"
|
||||||
|
Path="IsReadOnly"
|
||||||
|
Converter="{x:Static BoolConverters.Not}" />
|
||||||
|
</MultiBinding>
|
||||||
|
</Button.IsVisible>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="2"
|
||||||
|
x:Name="PART_SearchButton"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Focusable="False"
|
||||||
|
Theme="{StaticResource ButtonIcon}"
|
||||||
|
hc:IconElement.Width="14"
|
||||||
|
Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessSplitConverter}, ConverterParameter='0,0,1,0'}"
|
||||||
|
hc:IconElement.Geometry="{StaticResource SearchGeometry}"
|
||||||
|
Foreground="{Binding BorderBrush, ElementName=border}" />
|
||||||
|
</Grid>
|
||||||
|
</HeaderedContentControl>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="SearchBarPlus.Small"
|
||||||
|
BasedOn="{StaticResource SearchBarPlus}"
|
||||||
|
TargetType="hc:SearchBar">
|
||||||
|
<Setter Property="hc:InfoElement.MinContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:InfoElement.ContentHeight"
|
||||||
|
Value="20" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheLeft"
|
||||||
|
Value="0,3,6,0" />
|
||||||
|
<Setter Property="hc:TitleElement.MarginOnTheTop"
|
||||||
|
Value="6,0,0,1" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="6,0" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="20" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
Reference in new issue
Block a user