This commit is contained in:
TheXamlGuy
2024-07-10 14:36:09 +01:00
parent c5b330d041
commit 38e2913cab
6 changed files with 167 additions and 41 deletions
@@ -0,0 +1,49 @@
using Avalonia;
namespace Toolkit.UI.Controls.Avalonia;
public class OverflowTemplateSettings :
AvaloniaObject
{
public static readonly StyledProperty<object?> PrimarySelectionProperty =
AvaloniaProperty.Register<OverflowTemplateSettings, object?>(nameof(PrimarySelection));
public static readonly StyledProperty<object?> SecondarySelectionProperty =
AvaloniaProperty.Register<OverflowTemplateSettings, object?>(nameof(SecondarySelection));
private bool isSelectionChanging;
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs args)
{
base.OnPropertyChanged(args);
if (!isSelectionChanging)
{
isSelectionChanging = true;
if (args.Property == PrimarySelectionProperty)
{
SecondarySelection = null;
}
else if (args.Property == SecondarySelectionProperty)
{
PrimarySelection = null;
}
isSelectionChanging = false;
}
}
public object? PrimarySelection
{
get => GetValue(PrimarySelectionProperty);
set => SetValue(PrimarySelectionProperty, value);
}
public object? SecondarySelection
{
get => GetValue(SecondarySelectionProperty);
set => SetValue(SecondarySelectionProperty, value);
}
}