A customized WPF window does not respect the area occupied by the task bar. In order to do this, you need support from the Win32 API.
The first method you will need is...
[DllImport("user32.dll")]
public static extern IntPtr MonitorFromWindow(IntPtr hwnd, int dwFlags);
The MonitorFromWindow function retrieves a handle to the display monitor that has the largest area of intersection with the bounding rectangle of a specified window. http://msdn.microsoft.com/en-us/library/windows/desktop/dd145064(v=vs.85).aspx
Set dwFlags = 2
The next one is...
[DllImport("user32.dll")]
public static extern bool GetMonitorInfo(HandleRef hmonitor,
[In, Out] MonitorInfoEx monitorInfo);
The GetMonitorInfo function retrieves information about a display monitor. http://msdn.microsoft.com/en-us/library/windows/desktop/dd144901(v=vs.85).aspx
The MonitorInfoEx struct looks like...
[StructLayout(LayoutKind.Sequential)]
public class MonitorInfoEx
{
public int cbSize;
public Rect rcMonitor;
public Rect rcWork;
public int dwFlags;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
public char[] szDevice;
}
The MONITORINFOEX structure contains information about a display monitor. http://msdn.microsoft.com/en-us/library/windows/desktop/dd145066(v=vs.85).aspx
The Rect being passed is...
[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
Of particular interest here is that you are getting the working area in DPI at its current resolution.
Finally, you'll need the HwndSource.FromHwnd method from the Interop namespace of the PresentationCore (WPF)
Once you have all the info together, you can use CompositionTarget.TransformFromDevice to... Gets a matrix that can be used to transform coordinates from the rendering destination device to this target. http://msdn.microsoft.com/en-us/library/system.windows.media.compositiontarget.transformfromdevice.aspx
... and that will give you the dimensions you need to position your customized window such that it respects the status bar.
WindowState
is set toWindowState.Maximized
. – Ming Slogar