Reputation: 930
I've a wpf window and i applied style for window header and added some code to maximize window with out covering task bar when i click on maximize button and its working fine. But the problem is when i drag window towards top window maximizing fully by hiding task bar so any one help me to get out of this.
Thanks, @nagaraju.
code for dragmove :
void OnTitleBarLeftButtonDown(object sender, MouseEventArgs e)
{
Window window = this.TemplatedParent as Window;
if (window != null)
{
window.DragMove();
}
}
maximize code:
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;
}
}
}
Upvotes: 2
Views: 1046
Reputation: 178630
Avoid a lot of hassle and don't do this yourself - use the shell integration library.
Upvotes: 1