Add WheelComboBox
This commit is contained in:
parent
6a8476c976
commit
4cfe72a63b
@ -0,0 +1,5 @@
|
||||
<ComboBox xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Controls.WheelComboBox">
|
||||
|
||||
</ComboBox>
|
||||
@ -0,0 +1,35 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Styling;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibationWinForms.AvaloniaUI.Controls
|
||||
{
|
||||
public partial class WheelComboBox : ComboBox, IStyleable
|
||||
{
|
||||
Type IStyleable.StyleKey => typeof(ComboBox);
|
||||
public WheelComboBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
|
||||
{
|
||||
var dir = Math.Sign(e.Delta.Y);
|
||||
if (dir == 1 && SelectedIndex > 0)
|
||||
SelectedIndex--;
|
||||
else if (dir == -1 && SelectedIndex < ItemCount - 1)
|
||||
SelectedIndex++;
|
||||
|
||||
base.OnPointerWheelChanged(e);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@
|
||||
Title="Book Details" Name="BookDetails"
|
||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||
|
||||
<Grid RowDefinitions="*,Auto,Auto,Auto">
|
||||
<Grid RowDefinitions="*,Auto,Auto,40">
|
||||
<Grid.Styles>
|
||||
<Style Selector="Button:focus">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
||||
@ -76,7 +76,7 @@
|
||||
VerticalAlignment="Center"
|
||||
Text="PDF" />
|
||||
|
||||
<ComboBox
|
||||
<controls:WheelComboBox
|
||||
Grid.Column="1"
|
||||
Width="150"
|
||||
MinHeight="25"
|
||||
@ -95,9 +95,9 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
||||
</ComboBox>
|
||||
</controls:WheelComboBox>
|
||||
|
||||
<ComboBox
|
||||
<controls:WheelComboBox
|
||||
IsEnabled="{Binding HasPDF}"
|
||||
Grid.Column="4"
|
||||
MinHeight="25"
|
||||
@ -117,7 +117,7 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
||||
</ComboBox>
|
||||
</controls:WheelComboBox>
|
||||
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||
xmlns:controls="clr-namespace:LibationWinForms.AvaloniaUI.Controls"
|
||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.LiberatedStatusBatchDialog"
|
||||
Title="Liberated status: Whether the book has been downloaded"
|
||||
MinWidth="400" MinHeight="120"
|
||||
@ -28,7 +29,7 @@
|
||||
VerticalAlignment="Center"
|
||||
Text="Book" />
|
||||
|
||||
<ComboBox
|
||||
<controls:WheelComboBox
|
||||
Width="130"
|
||||
MinHeight="25"
|
||||
Height="25"
|
||||
@ -45,7 +46,7 @@
|
||||
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</controls:WheelComboBox>
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user