[英]Maximized window with WindowStyle=“None” doesn't move again using keyboard SHIFT+WIN+LEFT/RIGHT
[英]WPF | C# - When WindowStyle = “None” and the window is maximized the Task Bar doesn't show up
WindowStyle="None"
時,如何查看任務欄。 我試圖通過刪除實際的窗口標題欄並使用dll來刪除邊框,以擁有自己的按鈕(關閉,最大化,最小化)。 易於維護和易於放入我的代碼將不勝感激。
提前致謝!
可能的解決方法之一是:限制窗口的最大大小。 例如:
C#代碼:
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
if (WindowState == WindowState.Normal)
{
System.Drawing.Rectangle rec = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle).WorkingArea;
MaxHeight = rec.Height;
MaxWidth = rec.Width;
ResizeMode = ResizeMode.NoResize;
WindowState = WindowState.Maximized;
}
else
{
MaxHeight = double.PositiveInfinity;
MaxWidth = double.PositiveInfinity;
ResizeMode = ResizeMode.CanResize;
WindowState = WindowState.Normal;
}
}
}
您需要在更改窗口狀態之前設置maxsize。 否則,在某些情況下它會出錯。 同樣不要忘記ResizeMode。
和xaml:
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" WindowStyle="None" Height="300" Width="300">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Width="75" Click="ButtonBase_OnClick"/>
</Grid>
</Window>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.