TextEraserButton.axaml.cs 771 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Avalonia;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. using Avalonia.Markup.Xaml;
  5. namespace SukiUI.Theme;
  6. public partial class TextEraserButton : UserControl
  7. {
  8. public TextEraserButton()
  9. {
  10. InitializeComponent();
  11. }
  12. private void InitializeComponent()
  13. {
  14. AvaloniaXamlLoader.Load(this);
  15. }
  16. public static readonly StyledProperty<string> TextProperty = AvaloniaProperty.Register<TextEraserButton, string>(nameof(Text), defaultValue: "");
  17. public string Text
  18. {
  19. get { return GetValue(TextProperty); }
  20. set
  21. {
  22. SetValue(TextProperty, value);
  23. }
  24. }
  25. private void Button_OnClick(object sender, RoutedEventArgs e)
  26. {
  27. Text = "_";
  28. Text = "";
  29. }
  30. }