using System.Windows.Controls; using System.Windows; namespace YY.Admin.Views.Dialogs { /// /// ServerSettingsDialogView.xaml 的交互逻辑 /// public partial class ServerSettingsDialogView : UserControl { public ServerSettingsDialogView() { InitializeComponent(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { var win = Window.GetWindow(this); if (win == null) return; // 必须先关闭 AllowsTransparency,再改 WindowStyle(否则会抛出: // 「当 AllowsTransparency 为 true 时,WindowStyle.None 是唯一有效值」) win.AllowsTransparency = false; win.WindowStyle = WindowStyle.SingleBorderWindow; win.ResizeMode = ResizeMode.CanResizeWithGrip; win.SizeToContent = SizeToContent.Manual; win.MinWidth = 520; win.MinHeight = 420; if (win.Width < 520) win.Width = 520; if (win.Height < 420) win.Height = 420; } } }