using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; using Microsoft.UI.Xaml.Data; using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; using Microsoft.UI.Xaml.Navigation; using RustTools.muqing; using RustTools.ViewModels; using Windows.Foundation; using Windows.Foundation.Collections; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. namespace RustTools.Views; /// /// 动态界面 /// public sealed partial class ConcernPage : Page { public ConcernViewModel ViewModels { get; set; } public ConcernPage() { ViewModels = App.GetService(); InitializeComponent(); } private void Page_SizeChanged(object sender, SizeChangedEventArgs e) { var height = ActualHeight; // 确保使用页面的实际高度 // 检查是否为有效的数值 if (!double.IsNaN(height) && !double.IsInfinity(height) && height > 16) { ListViewA.Height = height - 36; ListViewB.Height = height - 16; } else { ListViewA.Height = 500; // 或者其他适当的默认值 ListViewB.Height = 500; // 或者其他适当的默认值 } } private void ItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args) { gj.sc("You invoked "); } private void ListViewA_SelectionChanged(object sender, SelectionChangedEventArgs e) { // 获取当前选中的项目 var selectedItem = ListViewA.SelectedItem; gj.sc(selectedItem); } private void ListViewA_Loaded(object sender, RoutedEventArgs e) { // 检查是否有项目并设置默认选中项为第一个项 if (ListViewA.Items.Count > 0) { ListViewA.SelectedIndex = 0; } } }