增加滚轮切换菜单功能

This commit is contained in:
liufei
2022-05-20 16:36:54 +08:00
parent d01a27b827
commit 84727d8040
2 changed files with 31 additions and 1 deletions

View File

@@ -8,7 +8,8 @@
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800"
>
<UserControl.Resources>
<!--左侧栏样式动画-->
@@ -104,6 +105,7 @@
SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
VirtualizingPanel.VirtualizationMode="Recycling"
SelectionChanged="Menu_SelectionChanged"
PreviewMouseWheel="Menu_MouseWheel"
>
<ListBox.Resources>
<ContextMenu x:Key="MenuDialog" Width="200">

View File

@@ -373,5 +373,33 @@ namespace GeekDesk.Control.UserControls.PannelCard
MainWindow.mainWindow.HidedSearchBox();
}
}
private void Menu_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Delta < 0)
{
int index = MenuListBox.SelectedIndex;
if (index < MenuListBox.Items.Count - 1)
{
index ++;
} else
{
index = 0;
}
MenuListBox.SelectedIndex = index;
} else if (e.Delta > 0)
{
int index = MenuListBox.SelectedIndex;
if (index > 0)
{
index --;
}
else
{
index = MenuListBox.Items.Count - 1;
}
MenuListBox.SelectedIndex = index;
}
}
}
}