tags:

views:

892

answers:

2

I want to achieve the same effect as Windows Media Player or Browser based Flash players which take up the ENTIRE (not even the taskbar is visible) real estate when maximised.

This works fine if the WindowState is set to Maximised and the WindowStyle is set to None in XAML so the app is started in that state. Problem is I want to start the app in a bordered window and when the user chooses, maximise as specified above. In the StateChanged handler I check for Maximised state and if this is the case I set the WindowStyle to None. This has the effect of maximising the window but NOT covering the taskbar. The following code will make this work as I want but its a hack and I'd like to clean it up:

if (WindowState == WindowState.Maximized)
{
    m_videoWindow.Maximise();

    WindowStyle = WindowStyle.None;

    //the following makes this work but I would like to clean it up
    Hide();
    Show();
}

EDIT This (from 2006 when still in CTP) mentions the problem and someone from MS states they hope to improve full screen support in the next version, have these improvements been made?

+3  A: 

This article explains it all: Maximizing window (with WindowStyle=None) considering Taskbar.

Also worth checking out: Custom Window Chrome in WPF.

Edit: Now new, is the WPF Shell Integration Library that allows complete restyle of the window chrome without the headaches of reimplementing move, resizing, etc.

Eduardo Molteni
Thanks Eduardo. I had read that but was hoping there was a solution which didn't require Win32. I'm sure there must be something, as the hack that I mention above works....
Simon Fox
I guess there is not, because the behavior is by design, so you can have a window that takes all the desktop, like BabySmash.
Eduardo Molteni
Is it not strange though that when initially loading the window with WindowStyle = None and WindowState = Maximised the taskbar is obscured but when maximising the window after its loaded this is not the case?
Simon Fox
@Simon: I do not see the behavior you are are describing. In my case always cover the taskbar
Eduardo Molteni
A: 

Hello Simon,

I don't know if this is ok for you, but you can resize the window to have the same size than the working area (that is, in most cases, all the screen except the taskbar) and locate it at 0,0 (top-left corner):

Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width; 
Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height; 
Left = 0; 
Top = 0;

The exact definition for the WorkingArea property (from MSDN) is:

Gets the working area of the display. The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.

Hope it helps

Fix
What if the taskbar is on top? Or you have multiple monitors?
Eduardo Molteni
In that case this won't work as expected.
Fix