Persistent window across multiple windows 10 virtual desktops?

天大地大妈咪最大 提交于 2019-12-01 13:24:08

You can detect the virtual desktop change, found a nice GitHub project with the necessary code as well as more functions that deal with Virtual Desktops in Windows 10.

Virtual Desktop GitHub

To get the event and simulate the window staying on every desktop you can do the following.

VirtualDesktop.CurrentChanged += (o, e) =>
{
    this.Dispatcher.Invoke(() =>
    {
        var h = new WindowInteropHelper(this).Handle;

        if (!VirtualDesktopHelper.IsCurrentVirtualDesktop(h))
        {
            this.MoveToDesktop(VirtualDesktop.Current);
        }
    });
};

The Dispatcher.Invoke is necessary because the event is on a different thread then the UI one, so the call must be marshaled to the UI thread.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!