"btnMin" Content="―" Style="{StaticResource MaterialDesignFlatMidBgButton}" /> "btnMax" Content="☐" Style="{StaticResource MaterialDesignFlatMidBgButton}" /> "btnClose" Content="✕" Style="{StaticResource MaterialDesignFlatMidBgButton}" />Xaml代码↑后端代码↓ btnMin.Click += (s, e) => { this.WindowState = WindowState.Minimized; }; btnMax.Click += (s, e) => { if (this.WindowState == WindowState.Maximized) this.WindowState = WindowState.Normal; else this.WindowState = WindowState.Maximized; }; btnClose.Click += (s, e) => { this.Close(); }; ColorZone.MouseMove += (s, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; ColorZone.MouseDoubleClick += (s, e) => { if (this.WindowState == WindowState.Normal) this.WindowState = WindowState.Maximized; else this.WindowState = WindowState.Normal; }; 界面是这样的↓
Xaml代码↑
后端代码↓
btnMin.Click += (s, e) => { this.WindowState = WindowState.Minimized; }; btnMax.Click += (s, e) => { if (this.WindowState == WindowState.Maximized) this.WindowState = WindowState.Normal; else this.WindowState = WindowState.Maximized; }; btnClose.Click += (s, e) => { this.Close(); }; ColorZone.MouseMove += (s, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; ColorZone.MouseDoubleClick += (s, e) => { if (this.WindowState == WindowState.Normal) this.WindowState = WindowState.Maximized; else this.WindowState = WindowState.Normal; };
界面是这样的↓