A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.1 KiB

using Avalonia.Controls;
namespace Avalonia.Automation.Peers
{
public class TextBlockAutomationPeer : ControlAutomationPeer
{
public TextBlockAutomationPeer(TextBlock owner)
: base(owner)
{
Owner.PropertyChanged += (a, e) =>
{
if (e.Property == TextBlock.TextProperty)
{
RaisePropertyChangedEvent(
AutomationElementIdentifiers.NameProperty,
e.OldValue,
e.NewValue);
}
};
}
public new TextBlock Owner => (TextBlock)base.Owner;
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Text;
}
protected override string? GetNameCore() => Owner.Inlines?.Text ?? Owner.Text;
protected override bool IsControlElementCore()
{
// Return false if the control is part of a control template.
return Owner.TemplatedParent is null && base.IsControlElementCore();
}
}
}