| 
 這個界面打開時不居中,得在wpf前臺的xmal文件頭寫一下居中,或者加一個開啟居中事件哦。
 
 類似下面代碼的居中設置事件:
 
 
   // 确保窗口加载后获取窗口大小
        window.Loaded += (_, _) =>
        {
            try
            {
                var screenWidth = SystemParameters.PrimaryScreenWidth;
                var screenHeight = SystemParameters.PrimaryScreenHeight;
                // 计算窗口居中位置
                double left = (screenWidth - window.ActualWidth) / 2;
                double top = (screenHeight - window.ActualHeight) / 2;
                // 设置窗口位置
                window.Left = left;
                window.Top = top;
            }
            catch (Exception ex)
            {
                Env.Printl($"Error setting window position: {ex.Message}");
            }
        };
 
 |