From ca3d6b50e3114da08e72132bd1f3d02e9e83254d Mon Sep 17 00:00:00 2001 From: liufei Date: Sat, 22 Jan 2022 14:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BC=A0=E6=A0=87=E6=82=AC?= =?UTF-8?q?=E5=81=9C=E5=88=87=E6=8D=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PannelCard/LeftCardControl.xaml | 7 ++- .../PannelCard/LeftCardControl.xaml.cs | 47 +++++++++++++++---- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml b/Control/UserControls/PannelCard/LeftCardControl.xaml index 45a10dd..1f6d242 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml @@ -21,8 +21,7 @@ - - + @@ -94,7 +93,7 @@ BorderThickness="0" Foreground="{x:Null}" SelectedIndex="{Binding AppConfig.SelectedMenuIndex}" VirtualizingPanel.VirtualizationMode="Recycling" - SelectionChanged="menus_SelectionChanged" + SelectionChanged="Menu_SelectionChanged" > @@ -122,7 +121,7 @@ - + /// 当修改菜单元素可见时 设置原菜单为不可见 并且不可选中 @@ -202,7 +203,7 @@ namespace GeekDesk.Control.UserControls.PannelCard IconfontWindow.Show(SvgToGeometry.GetIconfonts(), menuInfo); } - private void menus_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e) { //设置对应菜单的图标列表 if (MenuListBox.SelectedIndex == -1) @@ -214,5 +215,31 @@ namespace GeekDesk.Control.UserControls.PannelCard appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList; } } + + /// + /// 鼠标悬停切换菜单 + /// + /// + /// + private void Menu_MouseEnter(object sender, MouseEventArgs e) + { + if (appData.AppConfig.HoverMenu) + { + new Thread(() => + { + Thread.Sleep(200); + this.Dispatcher.Invoke(() => + { + ListBoxItem lbi = sender as ListBoxItem; + if (lbi.IsMouseOver) + { + int index = MenuListBox.ItemContainerGenerator.IndexFromContainer(lbi); + MenuListBox.SelectedIndex = index; + } + }); + }).Start(); + } + } + } }