Files
Libation/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs
Michael Bucari-Tovo 3ab1edc076 Code Cleanup
Make fields readonly
Remove unnecessary casts
Format document
Remove unnecessary usings
Sort usings
Use file-level namespaces
Order modifiers
2026-02-05 12:48:44 -07:00

32 lines
605 B
C#

using Avalonia.Controls;
using Avalonia.Input;
using System;
namespace LibationAvalonia.Controls;
public partial class WheelComboBox : ComboBox
{
protected override Type StyleKeyOverride => typeof(ComboBox);
public WheelComboBox()
{
InitializeComponent();
}
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
var dir = Math.Sign(e.Delta.Y);
if (dir == 1 && SelectedIndex > 0)
{
SelectedIndex--;
e.Handled = true;
}
else if (dir == -1 && SelectedIndex < ItemCount - 1)
{
SelectedIndex++;
e.Handled = true;
}
base.OnPointerWheelChanged(e);
}
}