我有一个 wpf 窗口,我为窗口标题应用了样式,并添加了一些代码来最大化窗口,当我单击最大化按钮并且它工作正常时,它不会覆盖任务栏。但问题是当我通过隐藏任务栏将窗口拖到顶部窗口最大化时,任何人都可以帮助我摆脱这种情况。
谢谢,@nagaraju。
dragmove 的代码:
void OnTitleBarLeftButtonDown(object sender, MouseEventArgs e)
{
Window window = this.TemplatedParent as Window;
if (window != null)
{
window.DragMove();
}
}
最大化代码:
void MaxButton_Click(object sender, RoutedEventArgs e)
{
Window window = this.TemplatedParent as Window;
if (window != null)
{
if (state=="MAX")
{
window.Width = 1181;
window.Height = 670;
window.WindowState = WindowState.Normal;
CenterWindowOnScreen();
state = "MIN";
}
else
{
//maxButton.ImageDown = "/images/normalpress.png";
//maxButton.ImageNormal = "/images/normal.png";
//maxButton.ImageOver = "/images/normalhot.png";
state = "MAX";
window.Width = SystemParameters.WorkArea.Width;
window.Height = SystemParameters.WorkArea.Height;
window.Top = SystemParameters.WorkArea.Top;
window.Left = SystemParameters.WorkArea.Left;
}
}
}