[英]WPF ToolWindow that is not showed in taskbar block the application
This is a problem that happens when you are in the follow situation: -Have a main window in my application -I create another window that doesn't show in task bar, and is a tool window. 当您处于以下情况时会发生这样的问题: - 在我的应用程序中有一个主窗口 - 我创建了另一个未在任务栏中显示的窗口,并且是一个工具窗口。 -I show the second window as a dialog window (from the main window) -I switch to another application running in my system, and when i came back to the application the main window is showed, but it is locked by the second windows, that is not showed.
- 我将第二个窗口显示为对话窗口(从主窗口) - 我切换到我系统中运行的另一个应用程序,当我回到应用程序时,显示主窗口,但它被第二个窗口锁定,没有表现出来。
This is the code of the second window: 这是第二个窗口的代码:
<Window x:Class="WpfApplication1.DialogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DialogWindow" Height="300" Width="300" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ShowInTaskbar="False">
<!--Some content-->
</Windows>
And this is the code that shows the second window: 这是显示第二个窗口的代码:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var dialogWindow = new DialogWindow();
dialogWindow.ShowDialog();
}
How can i solve this problem, and still showing a dialog windows that doesn't shows in task bar? 我如何解决这个问题,仍然显示一个没有在任务栏中显示的对话框窗口?
I think you should set the DialogWindow.Owner
property to the parent window. 我认为你应该将
DialogWindow.Owner
属性设置为父窗口。 See this answer WPF: How do I set the Owner Window of a Dialog shown by a UserControl? 请参阅此答案WPF:如何设置UserControl显示的对话框的所有者窗口?
private void Button_Click_1(object sender, RoutedEventArgs e)
{
var dialogWindow = new DialogWindow();
dialogWindow.Owner = Window.GetWindow(this)
dialogWindow.ShowDialog();
}
That should put the DialogWindow
modally in front of its parent at all times. 这应该
DialogWindow
将DialogWindow
模态地放在其父级之前。
将TopMost=True
设置为对话框窗口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.