using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; namespace WpfApp.Utils; public static class WindowHelper { /// /// 通用窗口打开方法 /// /// 要显示的页面实例 /// 窗口标题 /// 窗口宽度 /// 窗口高度 /// 是否允许调整大小 public static void ShowPageDialog(Page page, string title, double width = 900, double height = 600, bool isResizable = false) { var navWin = new NavigationWindow { Content = page, Title = title, Width = width, Height = height, ShowsNavigationUI = false, WindowStartupLocation = WindowStartupLocation.CenterOwner, WindowStyle = WindowStyle.ToolWindow, Owner = Application.Current.MainWindow, ResizeMode = isResizable ? ResizeMode.CanResize : ResizeMode.NoResize }; navWin.ShowDialog(); } }