应用程序初始化后最大化时,样式=无封面任务栏的WPF窗口

问题描述:

我希望获得与Windows Media Player或基于浏览器的Flash播放器相同的效果,当它们最大化时,它们占用整个(甚至看不到任务栏)房地产.

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 maximized.

如果在XAML中将WindowState设置为Maximized并将WindowStyle设置为None,则此功能很好,因此应用程序将在该状态下启动.问题是我想在带边框的窗口中启动应用程序,并且当用户选择时,请按照上面的指定最大化.在StateChanged处理程序中,我检查Maximized状态,如果是这种情况,我将WindowStyle设置为None.这具有最大化窗口但不覆盖任务栏的效果.以下代码将按我的意愿进行此工作,但它是一个hack,我想对其进行清理:

This works fine if the WindowState is set to Maximized 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, maximize as specified above. In the StateChanged handler I check for Maximized state and if this is the case I set the WindowStyle to None. This has the effect of maximizing 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.Maximize();

    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?

本文对此进行了全部解释:

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

也值得一试:在WPF中使用自定义窗口Chrome .

编辑:现在是WPF Shell集成库的新增功能,该库可以完全重新设置窗口镶边的样式,而无需重新实现移动,调整大小等麻烦.

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.

编辑2015 :Shell集成库现已集成到WPF中,MS取消了代码

Edit 2015: Shell Integration Library is now integrated in WPF and MS retired the code