using Avalonia; using Avalonia.Controls; using Avalonia.Data; using Avalonia.Markup.Xaml; using System.Windows.Input; namespace InABox.Avalonia.Components; public partial class SearchBar : UserControl { public static readonly StyledProperty PlaceholderTextProperty = AvaloniaProperty.Register(nameof(PlaceholderText), "Search..."); public string PlaceholderText { get => GetValue(PlaceholderTextProperty); set => SetValue(PlaceholderTextProperty, value); } public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(nameof(Command), null); public ICommand? Command { get => GetValue(CommandProperty); set => SetValue(CommandProperty, value); } public static readonly StyledProperty TextProperty = AvaloniaProperty.Register(nameof(Text), "", defaultBindingMode: BindingMode.TwoWay); public string Text { get => GetValue(TextProperty); set => SetValue(TextProperty, value); } public SearchBar() { InitializeComponent(); } private void TextBox_TextChanged(object? sender, TextChangedEventArgs e) { if (Command is not null && Command.CanExecute(null)) { Command.Execute(null); } } }