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"
|
Title="Book Details" Name="BookDetails"
|
||||||
Icon="/AvaloniaUI/Assets/libation.ico">
|
Icon="/AvaloniaUI/Assets/libation.ico">
|
||||||
|
|
||||||
<Grid RowDefinitions="*,Auto,Auto,Auto">
|
<Grid RowDefinitions="*,Auto,Auto,40">
|
||||||
<Grid.Styles>
|
<Grid.Styles>
|
||||||
<Style Selector="Button:focus">
|
<Style Selector="Button:focus">
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" />
|
||||||
@ -75,8 +75,8 @@
|
|||||||
Margin="0,0,10,0"
|
Margin="0,0,10,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="PDF" />
|
Text="PDF" />
|
||||||
|
|
||||||
<ComboBox
|
<controls:WheelComboBox
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="150"
|
Width="150"
|
||||||
MinHeight="25"
|
MinHeight="25"
|
||||||
@ -95,16 +95,16 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
|
|
||||||
</ComboBox>
|
</controls:WheelComboBox>
|
||||||
|
|
||||||
<ComboBox
|
<controls:WheelComboBox
|
||||||
IsEnabled="{Binding HasPDF}"
|
IsEnabled="{Binding HasPDF}"
|
||||||
Grid.Column="4"
|
Grid.Column="4"
|
||||||
MinHeight="25"
|
MinHeight="25"
|
||||||
Height="25"
|
Height="25"
|
||||||
Width="150"
|
Width="150"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
SelectedItem="{Binding PdfLiberatedSelectedItem, Mode=TwoWay}"
|
SelectedItem="{Binding PdfLiberatedSelectedItem, Mode=TwoWay}"
|
||||||
Items="{Binding PdfLiberatedItems}">
|
Items="{Binding PdfLiberatedItems}">
|
||||||
|
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
@ -117,7 +117,7 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
|
|
||||||
</ComboBox>
|
</controls:WheelComboBox>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||||
|
xmlns:controls="clr-namespace:LibationWinForms.AvaloniaUI.Controls"
|
||||||
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.LiberatedStatusBatchDialog"
|
x:Class="LibationWinForms.AvaloniaUI.Views.Dialogs.LiberatedStatusBatchDialog"
|
||||||
Title="Liberated status: Whether the book has been downloaded"
|
Title="Liberated status: Whether the book has been downloaded"
|
||||||
MinWidth="400" MinHeight="120"
|
MinWidth="400" MinHeight="120"
|
||||||
@ -27,8 +28,8 @@
|
|||||||
Margin="0,0,10,0"
|
Margin="0,0,10,0"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="Book" />
|
Text="Book" />
|
||||||
|
|
||||||
<ComboBox
|
<controls:WheelComboBox
|
||||||
Width="130"
|
Width="130"
|
||||||
MinHeight="25"
|
MinHeight="25"
|
||||||
Height="25"
|
Height="25"
|
||||||
@ -45,7 +46,7 @@
|
|||||||
|
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</controls:WheelComboBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user