Multi-Platform Package Manager for Stable Diffusion
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.

35 lines
870 B

using System.Diagnostics.CodeAnalysis;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Xaml.Interactivity;
namespace StabilityMatrix.Avalonia.Behaviors;
/// <summary>
/// Behavior that sets tooltip to null if the DisableOn condition is true.
/// </summary>
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public class ConditionalToolTipBehavior : Behavior<Control>
{
public static readonly StyledProperty<bool> 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);
}
}
}