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; - } - } }