我在
Windows 8.1上使用自己的样式WPF窗口时遇到了一些问题.我用WindowChrome编写了一个简单的透明WPF窗口,用于默认的窗口拖动行为:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300" Background="Transparent"
AllowsTransparency="True" WindowStyle="None">
<WindowChrome.WindowChrome>
<WindowChrome />
</WindowChrome.WindowChrome>
<Border Background="Gray" CornerRadius="20">
<Grid>
</Grid>
</Border>
</Window>
Windows 8.1设置:
> 2台带扩展桌面的显示器
>任务栏仅在主桌面上可见
摄制:
>启动WPF应用程序
>在辅助屏幕上移动窗口
>最大化辅助屏幕上的窗口(例如,将窗口对接在顶部)
>恢复窗口并将其从辅助屏幕拖动到主屏幕
– >当鼠标进入主屏幕时,任务栏图标将完全消失!
如果再次执行相同的repro,则会再次出现图标.
我也尝试使用.NET 4.5或.NET 4.5.1!
有谁能解释这个问题?
谢谢!
经过一些试验和错误调试后,我发现,窗口可见性设置为false,然后更新系统菜单,然后将该设置更改为true.
我认为这不是必要的,并产生这个令人讨厌的问题
这是WindowChromeWorker的方法
private void _UpdateSystemMenu(WindowState? assumeState)
{
const MF mfEnabled = MF.ENABLED | MF.BYCOMMAND;
const MF mfdisabled = MF.GRAYED | MF.disABLED | MF.BYCOMMAND;
WindowState state = assumeState ?? _GetHwndState();
if (null != assumeState || _lastMenuState != state)
{
_lastMenuState = state;
bool modified = _ModifyStyle(WS.VISIBLE,0);
IntPtr hmenu = NativeMethods.GetSystemMenu(_hwnd,false);
if (IntPtr.Zero != hmenu)
{
// change menu items
...
}
if (modified)
{
_ModifyStyle(0,WS.VISIBLE);
}
}
}
所以你可以尝试看看我的分支
WPF Shell Integration Library (Ex)tended Edition
原始来源可以找到here
here也是一个小测试应用程序
希望有所帮助