using System.Diagnostics.CodeAnalysis;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Xaml.Interactivity;
namespace StabilityMatrix.Avalonia.Behaviors;
///
/// Behavior that sets tooltip to null if the DisableOn condition is true.
///
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class ConditionalToolTipBehavior : Behavior
{
public static readonly StyledProperty DisableOnProperty = AvaloniaProperty.Register<
ConditionalToolTipBehavior,
bool
>("DisableOn");
public bool DisableOn
{
get => GetValue(DisableOnProperty);
set => SetValue(DisableOnProperty, value);
}
protected override void OnAttached()
{
base.OnAttached();
if (DisableOn)
{
ToolTip.SetTip(AssociatedObject!, null);
}
}
}