[英]WPF | C# - When WindowStyle = “None” and the window is maximized the Task Bar doesn't show up
How can I be able to see the taskbar when WindowStyle="None"
. WindowStyle="None"
时,如何查看任务栏。 I'm trying to have my own buttons (Close, Maximize, Minimize) by removing the actual window title bar and using a dll too remove the border. 我试图通过删除实际的窗口标题栏并使用dll来删除边框,以拥有自己的按钮(关闭,最大化,最小化)。 Easy to maintain and easy to put in my code would be greatly appreciated.
易于维护和易于放入我的代码将不胜感激。
Thanks in advanced! 提前致谢!
One of the possible fix to do this is: to limit the max size of window. 可能的解决方法之一是:限制窗口的最大大小。 For example:
例如:
C# code: 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;
}
}
}
You need to set maxsize just before changing of window state. 您需要在更改窗口状态之前设置maxsize。 Otherwise, in some cases it works wrong.
否则,在某些情况下它会出错。 Also don't forget about ResizeMode.
同样不要忘记ResizeMode。
And xaml: 和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.