简体   繁体   English

主窗口中的浮动窗口

[英]Floating window in main window

I have a WPF window application. 我有一个WPF窗口应用程序。

An addWindow() method creates another window and place it next to main window (window position and size is configured in settings). addWindow()方法创建另一个窗口并将其放置在主窗口旁边(窗口位置和大小在设置中配置)。 That caused me to add another monitor in order to view the added window. 这导致我添加了另一个监视器以查看添加的窗口。

How can I add that second window to same screen (as a small floating window at top right corner, etc) and allow user to switch between the views ? 如何将第二个窗口添加到同一屏幕(如右上角的小浮动窗口等)并允许用户在视图之间切换?

Current method implementation: 当前方法的实现:

private void addWindow()
{
   this.myScreen = new Project.myMonitorWindow();
   this.myScreen.init();
   this.myScreen.Show();
}

I think a simple solution is to use a popup (example at the bottom in the linked page). 我认为一个简单的解决方案是使用弹出窗口 (在链接页面底部的示例)。 You can make it act like a regular window, and you can position it relative to an element from the calling window. 您可以使其像常规窗口一样工作,并且可以将其相对于调用窗口中的元素定位。 Not sure what you mean by "switching between the views", but it also has a parameter called StaysOpen (bool), and if StaysOpen = false, that means it will close when you click outside the popup's boundaries. 不确定“在视图之间切换”是什么意思,但是它还有一个名为StaysOpen(布尔)的参数,如果StaysOpen = false,则意味着在弹出窗口边界之外单击时它将关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM