Selaa lähdekoodia

主页-最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑

OYXH\oyxh 1 vuosi sitten
vanhempi
commit
f9964308c9

+ 6 - 6
PDF Office/Views/HomePanel/HomeGuidContent.xaml

@@ -15,10 +15,10 @@
     mc:Ignorable="d">
     <Grid>
         <ScrollViewer
-            PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"
-            PanningMode="VerticalFirst"
             x:Name="scrollView"
             VerticalAlignment="Stretch"
+            PanningMode="VerticalFirst"
+            PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"
             VerticalScrollBarVisibility="Visible">
             <Grid>
                 <Grid.RowDefinitions>
@@ -27,13 +27,13 @@
                 </Grid.RowDefinitions>
                 <!--快捷工具
                 <pDFTools:QuickToolsContent x:Name="hometool" Margin="32" />-->
-                <ContentControl
-            prism:RegionManager.RegionName="{Binding HomeToolRegionName}" Margin="24"/>
+                <ContentControl Margin="24" prism:RegionManager.RegionName="{Binding HomeToolRegionName}" />
                 <recentFiles:RecentFilesContent
                     x:Name="Recentlist"
                     Grid.Row="1"
-                    Margin="24,0" />
+                    Margin="24,0"
+                    MouseDown="Recentlist_MouseDown" />
             </Grid>
         </ScrollViewer>
     </Grid>
-</UserControl>
+</UserControl>

+ 36 - 3
PDF Office/Views/HomePanel/HomeGuidContent.xaml.cs

@@ -1,4 +1,5 @@
-using System.Windows;
+using PDF_Master.Views.HomePanel.RecentFiles;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
 using System.Windows.Media;
@@ -45,6 +46,38 @@ namespace PDF_Master.Views.HomePanel
                 if (foundChild != null) break;
             }
             return foundChild;
-        }
+        }
+
+        private void Recentlist_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
+            if (sender is RecentFilesContent recentFilesContent)
+            {
+                if (recentFilesContent.GridRecentFilesList.Visibility == Visibility.Visible)
+                {
+                    var point = e.GetPosition(recentFilesContent.GridRecentFilesList);
+                    var result = VisualTreeHelper.HitTest(recentFilesContent.GridRecentFilesList, point);
+                    if (result != null)
+                    {
+                        if (recentFilesContent.GridRecentFilesList.SelectedIndex != -1)
+                        {
+                            recentFilesContent.GridRecentFilesList.SelectedIndex = -1;
+                        }
+                    }
+                }
+                else if (recentFilesContent.RecentFilesList.Visibility == Visibility.Visible)
+                {
+                    var point = e.GetPosition(recentFilesContent.RecentFilesList);
+                    var result = VisualTreeHelper.HitTest(recentFilesContent.RecentFilesList, point);
+                    if (result != null)
+                    {
+                        if (recentFilesContent.RecentFilesList.SelectedIndex != -1)
+                        {
+                            recentFilesContent.RecentFilesList.SelectedIndex = -1;
+                        }
+                    }
+                }
+            }
+        }
     }
-}
+}

+ 9 - 8
PDF Office/Views/HomePanel/RecentFiles/RecentFilesContent.xaml.cs

@@ -238,15 +238,16 @@ namespace PDF_Master.Views.HomePanel.RecentFiles
         {
             if (e.Key == Key.Escape)
             {
+                //Windows:最近文件列表补充点击空白处取消选中;移除Esc取消选中逻辑
                 //点击ESC取消选中
-                if (GridRecentFilesList.Visibility == Visibility.Visible)
-                {
-                    GridRecentFilesList.SelectedIndex = -1;
-                }
-                else
-                {
-                    RecentFilesList.SelectedIndex = -1;
-                }
+                //if (GridRecentFilesList.Visibility == Visibility.Visible)
+                //{
+                //    GridRecentFilesList.SelectedIndex = -1;
+                //}
+                //else
+                //{
+                //    RecentFilesList.SelectedIndex = -1;
+                //}
             }
         }