feat: add new class inheritance mechanism.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Irihi.Avalonia.Shared.Contracts;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public class AutoCompleteBox: Avalonia.Controls.AutoCompleteBox
|
||||
public class AutoCompleteBox: Avalonia.Controls.AutoCompleteBox, IClearControl
|
||||
{
|
||||
protected override Type StyleKeyOverride { get; } = typeof(Avalonia.Controls.AutoCompleteBox);
|
||||
|
||||
// protected override Type StyleKeyOverride { get; } = typeof(Avalonia.Controls.AutoCompleteBox);
|
||||
private TextBox? _text;
|
||||
static AutoCompleteBox()
|
||||
{
|
||||
MinimumPrefixLengthProperty.OverrideDefaultValue<AutoCompleteBox>(0);
|
||||
@@ -17,6 +20,12 @@ public class AutoCompleteBox: Avalonia.Controls.AutoCompleteBox
|
||||
this.AddHandler(PointerPressedEvent, OnBoxPointerPressed, RoutingStrategies.Tunnel);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
_text = e.NameScope.Get<TextBox>("PART_TextBox");
|
||||
}
|
||||
|
||||
private void OnBoxPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (Equals(sender, this) && e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
@@ -30,4 +39,9 @@ public class AutoCompleteBox: Avalonia.Controls.AutoCompleteBox
|
||||
base.OnGotFocus(e);
|
||||
SetCurrentValue(IsDropDownOpenProperty, true);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
SetCurrentValue(SelectedItemProperty, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user