From e3b741f07d3f70fcd3434d3c225c6f3ebd9b81ab Mon Sep 17 00:00:00 2001 From: muqing <1966944300@qq.com> Date: Fri, 6 Dec 2024 09:29:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=B3=E6=B3=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=92=8C=E7=99=BB=E9=99=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RustTools/Views/ConcernPage.xaml | 1 - RustTools/Views/ConcernPage.xaml.cs | 15 ++++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/RustTools/Views/ConcernPage.xaml b/RustTools/Views/ConcernPage.xaml index 96f97a8..a2506fd 100644 --- a/RustTools/Views/ConcernPage.xaml +++ b/RustTools/Views/ConcernPage.xaml @@ -40,7 +40,6 @@ Grid.Column="0" ItemTemplate="{StaticResource ConCernItem}" ItemsSource="{x:Bind communitylist}" - Loaded="ListViewA_Loaded" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" SelectionChanged="ListViewA_SelectionChanged" diff --git a/RustTools/Views/ConcernPage.xaml.cs b/RustTools/Views/ConcernPage.xaml.cs index 734f318..548d06c 100644 --- a/RustTools/Views/ConcernPage.xaml.cs +++ b/RustTools/Views/ConcernPage.xaml.cs @@ -64,8 +64,10 @@ public sealed partial class ConcernPage : Page communitylist.Add(item); } - - ListViewA.SelectedIndex = 0; + if (ListViewA.Items.Count > 0) + { + ListViewA.SelectedIndex = 0; + } } catch (Exception e) { @@ -124,13 +126,4 @@ public sealed partial class ConcernPage : Page gj.sc(selectedItem); dongtaixiaoxi(); } - - private void ListViewA_Loaded(object sender, RoutedEventArgs e) - { - // 检查是否有项目并设置默认选中项为第一个项 - if (ListViewA.Items.Count > 0) - { - ListViewA.SelectedIndex = 0; - } - } }